安装inotify
yum -y install inotify-tools
写同步脚本
Path=/data
IP=172.16.100.20
/usr/bin/inotfywait -mrq --format '%w%f' -e close_write,delete $Path \
| while read i
do
if [ -f $i ];then
rsync -az $i --delete vir_rsync@Ip::bak_mod --password-file=/etc/rsync.password
else
cd $Path && \
rysnc -az ./ --delete vir_rsync@Ip::bak_mod --password-file=/etc/rsync.password
fi
done