#!/bin/bash
source_dir=/data/www/game_analys/static
LOG=/root/inotify-backend_static.log
IPS="10.105.37.116 10.105.74.140"
[ -d $source_dir ] || exit 2
inotifywait -rmq --timefmt '%Y%m%d%H:%M' --format '%T %e %w%f' -e create,move,delete,modify,CLOSE_WRITE $source_dir | while read line;do
echo -e "\n\n[`date +%F_%T`]" >> $LOG
echo $line >> $LOG
#delete_file=`cat inotify.log |grep DELETE|awk '{printf $3" "}'`
#changed_file=`find $source_dir -mtime -1 |xargs echo`
for ip in $IPS
do
echo -e "\n\n[`date +%F_%T`] $ip" >> /root/rsync-backend_static.log
rsync -azv -P --delete --password-file=/etc/rsyncd.scrt $source_dir dbrNGai@$ip::backend_static >> /root/rsync-backend_static.log
done
done