LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

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

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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.
 
1 members found this post helpful.
Old 08-04-2012, 12:38 AM   #3
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Original Poster
Rep: Reputation: 4
Hi,

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


Reply

Tags
rsync



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 01:39 AM
Why a Process shows multiple process ids(pids) ? thelink123 Linux - Newbie 1 11-10-2010 12:18 AM
Cron'd rsync process out of control. ghostmac Linux - Software 2 11-12-2008 09:30 PM
AWK/SED Multiple pattern matching over multiple lines issue GigerMalmensteen Programming 15 12-03-2006 05:08 PM
apache, process owner, and rsync/ssh question Kruel Linux - Networking 0 03-01-2002 12:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:40 AM.

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