rsync+inotify 脚本

rsync+inotify 脚本,第1张

概述#!/bin/sh chkconfig: 2345 10 90 description: This Rsync script based on inotify. date: 2019-04-08 version: 1.0 src1=/test #监控的路径des1=uploaders/ #需要同步到那台服务器上的rsync模块名称rsync_passwd_file=/etc/server.pass #!/bin/sh

chkconfig: 2345 10 90 description: This Rsync script based on inotify. date: 2019-04-08 version: 1.0

src1=/test #监控的路径des1=uploaders/ #需要同步到那台服务器上的rsync模块名称rsync_passwd_file=/etc/server.pass #密码交互文件ip=192.168.8.178 #需要同步的IPuser=yihong #需要同步方的用户inotify=/usr/bin/inotifywaitcd ${src1}$inotify -mrq --timefmt ‘%y-%m-%d %H:%M‘ --format ‘%T %w%f %e‘ --event modify,create,move,delete,attrib ./ |while read filedoINO_EVENT=$(echo $file | awk ‘{print $4}‘)INO_file=$(echo $file | awk ‘{print $3}‘)echo "-------------------------$(date)---------------------------" >> /var/log/rsync.log 2>&1echo $file >>/var/log/rsync.log 2>&1if [[ $INO_EVENT=‘CREATE‘ ]]||[[ $INO_EVENT=‘MODIFY‘ ]]||[[ $INO_EVENT=‘CLOSE_WRITE‘ ]]||[[ $INO_EVENT=‘MOVED_TO‘ ]];thenecho ‘CREATE or MODIFY or CLOSE_WRITE or MOVED_TO‘ >> /var/log/rsync.log 2>&1rsync -avzcR $(dirname ${INO_file}) ${user}@${ip}::${des1} --password-file=${rsync_passwd_file} >>/var/log/rsync.log 2>&1fiif [[ $INO_EVENT=‘DELETE‘ ]]||[[ $INO_EVENT=‘MOVED_FROM‘ ]];thenecho ‘DELETE or MOVED_FROM‘ >>/var/log/rsync.log 2>&1rsync -avzR --delete $(dirname ${INO_file}) ${user}@${ip}::${des1} --password-file=${rsync_passwd_file}>>/var/log/rsync.log 2>&1fiif [[ $INO_EVENT=‘ATTRIB‘ ]];thenecho ‘ATTRIB‘ >>/var/log/rsync.log 2>&1if [ ! -d "$INO_file" ];thenrsync -avzcR $(dirname ${INO_file}) ${user}@${ip}::${des1} --password-file=${rsync_passwd_file}>>/var/log/rsync.log 2>&1fifIDone&

总结

以上是内存溢出为你收集整理的rsync+inotify 脚本全部内容,希望文章能够帮你解决rsync+inotify 脚本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/1023964.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存