ref:
https://www.cnblogs.com/MacoLee/p/5633650.html
https://wenda.so.com/q/1505308236213470
http://blog.51cto.com/11935263/2054760
#!/bin/bash # host=192.168.1.22 presrc=~/git/svc-iso src=$presrc/app src1=~/git/svc-iso/src/postinstall des=~/haishen/svc-t/postinstall user=webuser inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src $src1 | while read files do # /usr/bin/rsync -vzrtopg --delete --progress --password-file=/usr/local/rsync/rsync.passwd $src $user@$host::$des # echo "${files} was rsynced" >>/tmp/rsync.log 2>&1 echo "${files} was rsynced" prsf=${files%%ATTRIB} prsf=${prsf%%CREATE} prsf=${prsf%%DELETE} prsf=${prsf%%MODIFY} prsf=${prsf##* } echo "source file is $prsf" rsf=${prsf##*git/svc-iso/} rsf=${rsf##src/} echo $rsf if [ "postinstall" == $rsf ]; then sfile=$src1 else sfile=$presrc fi echo "rsync source ${files} to $des/$rsf" rsync -av --delete --progress ${prsf} $des/$rsf # rsync -av $src $des done ~