关于linux下文件实时双向同步问题
我按照网上的文档通过inotify+unison实现了两台centos服务器的实时双向同步,文档中给了一个shell脚本,实现实时同步一个文件夹,如果我想实时同步两个文件...
我按照网上的文档通过inotify+unison实现了两台centos服务器的实时双向同步,文档中给了一个shell脚本,实现实时同步一个文件夹,如果我想实时同步两个文件夹应该怎么修改这个shell脚本?求大神指点。
下面是两台服务器的脚本:
server1地址:192.168.20.1
shell:
#/bin/bash
ip2="192.168.20.2"
src2="/home/server1/"
dst2="/home/server2/"
/usr/local/bin/inotifywait -mrq -e create,delete,modify,move $src2 | while read line; do
/usr/local/bin/unison -batch $src2 ssh://$ip2/$dst2
echo -n "$line " >> /var/log/inotify.log
echo `date | cut -d " " -f1-4` >> /var/log/inotify.log
done
server2 地址192.168.20.2
shell
#/bin/bash
ip1="192.168.20.1"
src1="/home/server2/"
dst1="/home/server1/"
/usr/local/bin/inotifywait -mrq -e create,delete,modify,move $src1 | while read line; do
/usr/local/bin/unison -batch $src1 ssh://$ip1/$dst1
echo -n "$line " >> /var/log/inotify.log
echo `date | cut -d " " -f1-4` >> /var/log/inotify.log
done 展开
下面是两台服务器的脚本:
server1地址:192.168.20.1
shell:
#/bin/bash
ip2="192.168.20.2"
src2="/home/server1/"
dst2="/home/server2/"
/usr/local/bin/inotifywait -mrq -e create,delete,modify,move $src2 | while read line; do
/usr/local/bin/unison -batch $src2 ssh://$ip2/$dst2
echo -n "$line " >> /var/log/inotify.log
echo `date | cut -d " " -f1-4` >> /var/log/inotify.log
done
server2 地址192.168.20.2
shell
#/bin/bash
ip1="192.168.20.1"
src1="/home/server2/"
dst1="/home/server1/"
/usr/local/bin/inotifywait -mrq -e create,delete,modify,move $src1 | while read line; do
/usr/local/bin/unison -batch $src1 ssh://$ip1/$dst1
echo -n "$line " >> /var/log/inotify.log
echo `date | cut -d " " -f1-4` >> /var/log/inotify.log
done 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询