LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-31-2013, 06:53 PM   #1
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,399

Rep: Reputation: 36
What happens if you run the same rsync command twice


I have a somewhat silly question. Say I have an rsync job setup in cron to run every 4 hours. For example, say it's 4am and the cron job kicks off. What happens if at 4:15am that cron'd rsync is still running, and someone logs on to the server and runs the exact same rsync command manually?

Will this cause issues or bad data? Will the user manually running it have something pop up on the screen saying that rsync is already doing something in these folders or anything?

If it matters, I usually use these options when I rsync (took it from one that was already setup by someone else on another server of mine)
-razpv -e ssh
 
Old 04-01-2013, 07:51 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,026

Rep: Reputation: 519Reputation: 519Reputation: 519Reputation: 519Reputation: 519Reputation: 519
I don't think anything will really happen - the files that were already synced will not be resynced as they already match for being updated.

You MIGHT get duplicate copying... but the one that finishes last will be the final copy, and the only way they would differ would be if the file changed while the first copy was being made, and the second copy got the updated blocks.

The only time corruption should occur is if the second rsync gets aborted in the middle of copying - it might truncate the file (I'm not sure though).

Last edited by jpollard; 04-01-2013 at 07:53 AM.
 
Old 04-01-2013, 07:54 AM   #3
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,399

Original Poster
Rep: Reputation: 36
I'm also thinking it might not be a huge deal, but really I'm not sure.
 
Old 04-01-2013, 11:38 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,368

Rep: Reputation: 586Reputation: 586Reputation: 586Reputation: 586Reputation: 586Reputation: 586
If it's between two locally mounted filesystems, I suspect you could probably get away with it. But, if either filesystem is remote (so that rsync tries to transmit diffs rather than whole files), I have bad feelings about what might happen if one instance calculates a diff and transmits it, but the other instance has updated the file in the meantime.
 
Old 04-01-2013, 12:01 PM   #5
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,458

Rep: Reputation: 440Reputation: 440Reputation: 440Reputation: 440Reputation: 440
if the first rsync is still running the 2nd one will not be allowed to run, you can only have one instance of rsync running at a time. its not a big deal.
 
Old 04-01-2013, 12:57 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,368

Rep: Reputation: 586Reputation: 586Reputation: 586Reputation: 586Reputation: 586Reputation: 586
Quote:
Originally Posted by lleb View Post
if the first rsync is still running the 2nd one will not be allowed to run, you can only have one instance of rsync running at a time. its not a big deal.
Perhaps that's true if you're connecting to a remote rsync server that was spawned as a service (I have no experience with that.), but it's certainly not true when running rsync with both source and destination local or when the remote process is spawned by a remote shell. I just tried it both ways, always with the same sources and same destinations, with no complaints from rsync.
 
Old 04-01-2013, 04:31 PM   #7
rjo98
Senior Member
 
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,399

Original Poster
Rep: Reputation: 36
That's a good point about a remote vs local rsync
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rsync dry run imagiro1 Linux - General 10 01-12-2012 12:20 PM
[SOLVED] Problem Getting rsync Script to run gjblackford Linux - General 7 02-25-2011 02:04 PM
rsync problems, can you look at my command? - Rsync gurus. Spuddy Linux - Software 4 09-21-2010 10:25 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM
rsync: getting a script to run before/after every instance? abolishtheun Linux - General 1 04-14-2009 07:04 AM


All times are GMT -5. The time now is 05:16 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration