System: CentOS 5.x
Software Required: rsync
Script content:
| The code is as follows |
Copy Code |
#!/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.
Original from: blog.slogra.com