Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
How to avoid Rsync Endless LoopAdrian Singer, 07-27-2009 |
Rsync is a great command-line sync tool, that allows fast replication from one web server to another.
If you are running more than one Rsync command in a cronjob, replicating several folders into a target machine, watch out for the Rsync endless loop bug.
There are two steps you can take to avoid this:
Step 1:
Consider this scenario:
Destination machine B has these two cronjobs, set to run every 5 minutes:
Since the folder /usr/home/something/ is also included by the first cronjob, this can easily cause the infamous Rsync endless loop bug.
The fix, add an --exclude to the first cronjob, like this:
Step 2:
If it takes more than 5 minutes for Rsync to complete, before the next instance runs, you're in trouble.
To be safe, write a php script that will check if the Rsync daemon is running, prior to launching another one.
If you are running more than one Rsync command in a cronjob, replicating several folders into a target machine, watch out for the Rsync endless loop bug.
There are two steps you can take to avoid this:
Step 1:
Consider this scenario:
Destination machine B has these two cronjobs, set to run every 5 minutes:
*/5 * * * * /usr/local/bin/rsync --progress --stats --archive -z --compress -t MachineA.com:/usr/home/ /usr/home/
*/5 * * * * /usr/local/bin/rsync --progress --stats --archive -z --compress -t MachineA.com:/usr/home/something/ /usr/home/something/
*/5 * * * * /usr/local/bin/rsync --progress --stats --archive -z --compress -t MachineA.com:/usr/home/something/ /usr/home/something/
Since the folder /usr/home/something/ is also included by the first cronjob, this can easily cause the infamous Rsync endless loop bug.
The fix, add an --exclude to the first cronjob, like this:
*/5 * * * * /usr/local/bin/rsync --exclude /usr/home/something/ --progress --stats --archive -z --compress -t MachineA.com:/usr/home/ /usr/home/
*/5 * * * * /usr/local/bin/rsync --progress --stats --archive -z --compress -t MachineA.com:/usr/home/something/ /usr/home/something/
*/5 * * * * /usr/local/bin/rsync --progress --stats --archive -z --compress -t MachineA.com:/usr/home/something/ /usr/home/something/
Step 2:
If it takes more than 5 minutes for Rsync to complete, before the next instance runs, you're in trouble.
To be safe, write a php script that will check if the Rsync daemon is running, prior to launching another one.
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

