Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-02-2012, 02:53 AM   #1
Registered: Jul 2010
Posts: 126

Rep: Reputation: 4
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 ?
Old 08-03-2012, 01:44 AM   #2
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,024

Rep: Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399Reputation: 1399

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

1 members found this post helpful.
Old 08-04-2012, 01:38 AM   #3
Registered: Jul 2010
Posts: 126

Original Poster
Rep: Reputation: 4

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



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rsync execution issue with crontab - Have given full path to rsync too!! Prabagaran Linux - Server 6 04-15-2011 02:39 AM
Why a Process shows multiple process ids(pids) ? thelink123 Linux - Newbie 1 11-10-2010 01:18 AM
Cron'd rsync process out of control. ghostmac Linux - Software 2 11-12-2008 10:30 PM
AWK/SED Multiple pattern matching over multiple lines issue GigerMalmensteen Programming 15 12-03-2006 06:08 PM
apache, process owner, and rsync/ssh question Kruel Linux - Networking 0 03-01-2002 01:25 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration