Today there is a server A to transfer all the Web site program to another server B up, but away from work time is only 1 hours, in order to work on time, simply wrote a shell script to monitor whether there is transmission, I first in the server a looked at the total size of the program 12G, with Du- SM View is 11517, the server will not be someone to send things up, so I can be assured that the capacity will not become larger.
System: CentOS 5.x
Software Required: rsync
Script content:
Copy Code code as follows:
#!/bin/bash
File= ' Du-sm/var/www/vhosts/|awk ' {print $} '
Ps= ' ps-c rsync--no-header|wc-l '
If ["$file" = "11517"];then
echo "Files downloaded!"
Else
If ["$ps" = "1"];then
Kill-9 $ (PS aux | grep rsync |grep-v grep| awk ' {print $} ')
Sleep 1
Nohup sh/root/rsync.sh &
Else
echo "Rsync is running ..."
Fi
Fi
The general idea of the script is to see if the folder size is the same size as server A, and if not, check that the rsync process is running, kill it if it isn't running, and then rerun the download script for rsync.
PS: Of course, this script is a bit shabby, not to detect the status of the process, if there is a zombie process, there is no way to deal with. Of course, I will not change here, we can modify their own.