使用inotify实现实时文件同步shell脚本

 
inotify.sh

#!/bin/bash


src=/data/www/
/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src |  while read file
do
      /usr/bin/rsync -arzuq --delete --progress $src 192.168.136.128::www/
      echo "  ${file} was rsynced" >>/tmp/rsync.log 2>&1
done


 

chmod +x inotify.sh  
 
./inotify.sh&   

 

 

作者: javaboy2012
Email:[email protected]
qq:    1046011462

你可能感兴趣的:(shell脚本,inotify,实时文件同步)