下载inotify:

wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz


解包安装:

tar xvf inotify-tools-3.14.tar.gz -C /usr/src

cd /usr/src/inotify-tools-3.14

./configure && make && make install


DIR=需要被监控的目录


同步脚本:

#!/bin/bash


inotifywait -rmsq -o /var/log/inotify.log --timefmt '%Y-%d-%m %H:%M' --format '%T %w%f %e' -e modify,delete,create,attrib,move $DIR \

| while read file

do

   rsync ......;

done


rsync方面就不详细了