1. 程式人生 > >inotify+rsync做實時同步

inotify+rsync做實時同步

progress create 同步 log echo amp etc let att

一、配置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

inotify+rsync做實時同步