inotify+rsync做实时同步

一、配置inotify随机启动

vi  /etc/rc.local
nohup /home/jenkins/inotify/inotify.sh > nohup.out 2>&1 &

二、inotify同步脚本

#!/bin/bash
#param
src=/home/jenkins/conf/
dst_module=/home/jenkins/conf/
user=jenkins
/usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e modify,delete,create,attrib ${src} | while read file
do
        rsync -vzrtopg --delete --progress ${src} ${user}@52.81.4.8:${dst_module}
        rsync -vzrtopg --delete --progress ${src} ${user}@52.8.74.8:${dst_module}
        rsync -vzrtopg --delete --progress ${src} ${user}@18.8.120.8:${dst_module}
        echo "${file} was rsyncd" >>/var/log/rsyncd.log 2>&1
done
原文地址:https://www.cnblogs.com/husbandmen/p/8893691.html