用rsync同步遠程服務器,由于設置的的同步間隔較短(5分鐘),這樣一旦網速問題導致5分鐘內同步不完。就會倒是同步紊亂,導致系統(tǒng)中很多rsync進程(# ps -aux | grep rsync)
解決方法
1、使用linux bash腳本 定時執(zhí)行,殺死多余的rsync進程
2、腳本內容如下
new3-dx:/var/bash# bash k-rsync.sh
Killed
new3-dx:/var/bash# cat k-rsync.sh
#!/bin/bash
#
# Propram:
# Kill the redundant Rsync process
# History:
# 2012/08/06 iranw<http://www./> First release
#
for i in `ps -ef |grep rsync |grep -v grep |awk {'print $2'}`
do
kill -9 $i
echo "Kill $i successed."
done
3、給腳本內容添加權限
new3-dx:/var/bash# chmod +x k-rsync.sh
4、執(zhí)行
# bash k-rsync.sh
5、可以講本腳本寫入到計劃任務 每天執(zhí)行一遍