inotify实时监测文件变化并同步到远程机器

#!/bin/bash
INOTIFY_CMD="inotifywait -mrq -e create,delete,move,modify,attrib /srv/salt/us-west"

RSYNC_CMD="rsync -avrz --delete --bwlimit=20000 --port  61873 --password-file=/etc/us-west-salt.psw /srv/salt/us-west/*  salt@54.203.210.244::US-WEST"

$INOTIFY_CMD | while read DIRECTORY EVENT FILE
do
    if [ $(pgrep rsync | wc -l) -le 0 ] ; then
        $RSYNC_CMD
    fi
done

 

posted @ 2024-06-27 17:59  羊脂玉净瓶  阅读(11)  评论(0)    收藏  举报