关于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个回答
展开全部
#server1地址:192.168.20.1
#shell:
#!/bin/bash
ip2="192.168.20.2"
ip3="192.168.20.3"
src2="/home/server1/"
dst2="/home/server2/"
dst3="/home/server3/"
/usr/local/bin/inotifywait -mrq -e create,delete,modify,move $src2 | while read line; do
/usr/local/bin/unison -batch $src2 ssh://$ip2/$dst2
/usr/local/bin/unison -batch $src2 ssh://$ip3/$dst3
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"
ip3="192.168.20.3"
src1="/home/server2/"
dst1="/home/server1/"
dst3="/home/server3/"
/usr/local/bin/inotifywait -mrq -e create,delete,modify,move $src1 | while read line; do
/usr/local/bin/unison -batch $src1 ssh://$ip1/$dst1
/usr/local/bin/unison -batch $src1 ssh://$ip3/$dst3
echo -n "$line " >> /var/log/inotify.log
echo `date | cut -d " " -f1-4` >> /var/log/inotify.log
done
server3 地址192.168.20.3
shell
#!/bin/bash
ip1="192.168.20.1"
ip2="192.168.20.2"
src3="/home/server3/"
dst1="/home/server1/"
dst2="/home/server2/"
/usr/local/bin/inotifywait -mrq -e create,delete,modify,move $src3 | while read line; do
/usr/local/bin/unison -batch $src3 ssh://$ip1/$dst1
/usr/local/bin/unison -batch $src3 ssh://$ip2/$dst2
echo -n "$line " >> /var/log/inotify.log
echo `date | cut -d " " -f1-4` >> /var/log/inotify.log
done
追问
谢谢大神,我明天去公司试试,没问题了来给你采纳
迪凯特科技(北京)有限公司
2023-07-28 广告
2023-07-28 广告
要从电脑的一个串行口接收数据并将其从另一个串行口发送出去,你可以使用以下步骤:1. 确定你要使用的两个串行口。在大多数计算机上,串行口通常被称为COM1、COM2等。确保你了解每个串行口的名称或编号。2. 编写一个程序来读取来自一个串行口的...
点击进入详情页
本回答由迪凯特科技(北京)有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |