标签:
rsync+inotify实现文件时实同步
uid = root
gid = root
use chroot = no
max connections = 5
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[www]
path=/data/httpd/wwwroot/
comment = update
ignore errors
read only = no
list = no
hosts allow = 192.168.0.0/255.255.255.0
auth users = root
uid = root
gid = root
secrets file = /etc/rsyncd.secrets
#!/bin/bash
src=/data/httpd/wwwroot/
des=www
host="192.168.0.6 192.168.0.7 192.168.0.8"
/usr/local/bin/inotifywait -mrq --timefmt ‘%d/%m/%y %H:%M‘ --format ‘%T %w%f%e‘ -e close_write,delete,create,attrib $src | while read files
do
for hostip in $host
do
rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.secrets $src root@$hostip::$des
done
echo "${files} was rsynced" >>/tmp/rsync.log 2>&1
done
标签:
原文地址:http://www.cnblogs.com/51runsky/p/4572414.html