Please add lock control for this program as well.
eg.
check lock file
while lock file exist, wait for 15 mins.
If lock file exist more than 4 hours, overwrite the lock.
execute sync part and rotation.
remove lock file.
Here are some reference for it:
usage of programe:
sync_home src_ip local_directory remote_directory number_of_rotation
原始代码:
#!/usr/bin/perl
$result=`ping 192.168.70.13 -c 2`;
if ($result = ~/0% packet loss/)
{
`/bin/rm -rf /home/helen7`;
`/bin/mv /home/helen6 /home/helen7`;
`/bin/mv /home/helen5 /home/helen6`;
`/bin/mv /home/helen4 /home/helen5`;
`/bin/mv /home/helen3 /home/helen4`;
`/bin/mv /home/helen2 /home/helen3`;
`/bin/mv /home/helen1 /home/helen2`;
`/bin/mv /home/helen /home/helen1`;
`/usr/bin/rsync -a /home/helen_tmp/ /home/helen/`;
`/usr/bin/rsync -azv --one-file-system 192.168.70.13:/home/helen/ /home/helen_tmp/ | mail -s "Helen Notebook backup done" `;
}
sync_home:
#!/usr/bin/perl
$result=`ping 192.168.70.13 -c 2`; if ($result = ~/0% packet loss/) { `/bin/rm -rf /home/helen7`; `/bin/mv /home/helen6 /home/helen7`; `/bin/mv /home/helen5 /home/helen6`; `/bin/mv /home/helen4 /home/helen5`; `/bin/mv /home/helen3 /home/helen4`; `/bin/mv /home/helen2 /home/helen3`; `/bin/mv /home/helen1 /home/helen2`; `/bin/mv /home/helen /home/helen1`; `/usr/bin/rsync -a /home/helen_tmp/ /home/helen/`; `/usr/bin/rsync -azv --one-file-system 192.168.70.13:/home/helen/ /home/helen_tmp/ | mail -s "Helen Notebook backup done" op@uniforce.net`; }
|
阅读(329) | 评论(0) | 转发(0) |