cd ${src} /usr/bin/inotifywait -rmq --format '%Xe %w%f' -e modify,delete,create,attrib,close_write,move ./ | while read file do INO_EVENT=$(echo $file | awk'{print $1}') INO_FILE=$(echo $file | awk'{print $2}') echo "----------------${data}-----------------" echo $file if [[$INO_EVENT =~ 'CREATE']] || [[$INO_EVENT =~ 'MODIFY']] || [[$INO_EVENT =~ 'CLOSE_WRITE']] || [[$INO_EVENT =~ 'MOVE_TO']] then echo 'Creat or Modify or Close_write or Moved_to' rsync -avzcR --password-file=${pswfile} $(dirname ${INO_FILE}) ${user}@$ip{1}::${des} && rsync -avzcR --password-file=${pswfile} $(dirname ${INO_FILE}) ${user}@$ip{2}::${des} fi
if [[$INO_EVENT =~ 'DELETE']] || [[$INO_EVENT =~ 'MOVE_FROM']] then echo 'Delete or Moved_from' rsync -avzR --delete --password-file=${pswfile} $(dirname ${INO_FILE}) ${user}@$ip{1}::${des} && rsync -avzR --delete --password-file=${pswfile} $(dirname ${INO_FILE}) ${user}@$ip{2}::${des} fi
if [[$INO_EVENT =~ 'ATTRIB']] then echo 'Attrib' if [ !-d "$INO_FILE" ] then rsync -avzcR --password-file=${pswfile} $(dirname ${INO_FILE}) ${user}@$ip{1}::${des} && rsync -avzcR --password-file=${pswfile} $(dirname ${INO_FILE}) ${user}@$ip{2}::${des} fi fi