我做了Unison+inotify双向同步,脚本文件位置:/root/inotify.sh。
脚本内容
#/bin/bash
ip2="172.30.1.23"
src2="/home/wwwroot/discuz/"
dst2="/home/wwwroot/discuz/"
/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
设置了开机启动
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.