- 安裝inotify-tools:
yum -y install inotify-tools
- 安裝svn
yum -y install subversion
- 啓動svn
svnserve -d -r /home/lee/svn/test
- 編寫腳本文件test.sh,實現svn與網站服務器上的數據同步
#!/bin/bash
while inotifywait -rq -e moved_to /home/lee/svn/db/revs/0/ &> /dev/null; do
sleep 1; (注意這裏要讓系統休眠1秒鐘,否則同步的是上一個版本的數據)
svn checkout file:////home/lee/svn/test/ /var/www/html &> /dev/null;
done &
- 運行腳本
. test.sh
二、inotify+rsync:
- 安裝軟件:
yum -y install rsync inotify-tools
- 配置rsync:
參考:http://blog.51cto.com/12173069/2069243
- 寫監控腳本:vim test.sh
#!/bin/bash
while inotifywait -rq -e modify,create,move,delete,attrib /home/lee/rsync/ &> /dev/null ; do
rsync -avz /home/lee/rsync/ --password-file=/root/passwd [email protected]::common &> /dev/null
done &
- 創建密碼應答文件:
vim /root/passwd
123456
- 運行:
chmod a+x test.sh
./test.sh