1 安裝 sync
yum install rsync -y
2 下載安裝inotify
wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
cd intotify-tools-3.14
./config
make && make install
## 安裝完畢查看 inotifywait,inotifywath是否已經存在
which inotifywait
/usr/local/bin/inotifywait
which intotifywatch
/usr/local/bin/inotifywatch
3 編寫shell
#vim /root/a2b.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /home/a|while read files
do
rsync -r -v --ignore-existing /home/a/ /home/b
done
4 更改腳本權限
chmod 0755 a2b.sh
5 運行shell
nohup sh kejiagaokao_upload.sh
6 測試OK
上傳文件1.txt到a目錄 ,到b目錄查看1.txt同步成功