What happens if you run the same rsync command twice
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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).
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.