-   Linux - Software (
-   -   Rsync causes issue over multiple process (

vzxen 08-02-2012 02:53 AM

Rsync causes issue over multiple process

I have a cronjob setup to rsync a folder with significant DATA and it runs every 6 hours.
Now sometimes the FILES are very very large and they dont finish transferring in 6 hours. But the CRON job gets executed and it deletes the TEMPORARY FILE that rsync creates when transferring the file. This causes rsync to go in a round robin situation where it deletes the temporary file if its not completed and the CPU usage goes to 100%.

How can I prevent this ?

evo2 08-03-2012 01:44 AM


the script launched by cron should first check to see if the previous rsync is still running, if it is should simply exit.

You can perform the check using ps. If you have pgrep installed you might find that simpler.

Alternatively you could have your script create some sort of lock file, and then test for that. Here is a *very* basic example just to give you the idea.


if [ -f $lockfile ] ; then
  exit 0
touch $lockfile
rsync blah blah blah
rm -f $lockfile



vzxen 08-04-2012 01:38 AM


Ok. Thanks for the idea.
This is a really good and simple solution.

All times are GMT -5. The time now is 03:35 PM.