LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Rsync causes issue over multiple process (http://www.linuxquestions.org/questions/linux-software-2/rsync-causes-issue-over-multiple-process-4175419910/)

vzxen 08-02-2012 02:53 AM

Rsync causes issue over multiple process
 
Hi,

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

Hi,

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.

Code:

#!/bin/sh
lockfile="/var/rsync_job.lock"
if [ -f $lockfile ] ; then
  exit 0
fi
touch $lockfile
rsync blah blah blah
rm -f $lockfile

HTH,

Evo2.

vzxen 08-04-2012 01:38 AM

Hi,

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


All times are GMT -5. The time now is 06:54 PM.