您的位置:首页 > 其它

Unison+inotify-tools实现Ubuntu主机间的多机触发式双向同步

2014-05-25 18:34 351 查看

安装OpenSSH

       在各台服务器上安装OpenSSH,使用如下命令:
       sudo apt-get install openssh
       该命令在你的机器上同时安装了SSH Server和SSH Client。

安装Unison

       在各个需要同步的服务器上执行以下命令安装unison:
sudo apt-get install unison

安装Inotify tools

在各个需要同步的服务器上执行以下命令安装inotify-tools:
       apt-get install inotify-tools

UNISON=`ps -ef |grep -v grep|grep -c inotifywait`

if [ ${UNISON} -lt 1 ]

then

#ip2="192.168.1.7"

src2="/home/hedy/src/"

dst2="/home/hedy/target/"

/usr/bin/inotifywait -mrq -e create,delete,modify,move $src2 | while read line

do

#/usr/local/bin/unison -batch $src2 ssh://$ip2/$dst2

/usr/bin/unison -batch $src2 $dst2

echo -n "$line " >> /home/hedy/log/inotify/inotify$(date +%u).log

echo ` date +%F\ %T " " -f1-4` >> /home/hedy/log/inotify/inotify$(date +%u).log

done

fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: