cronning rsync

matthew.2.burgess at matthew.2.burgess at
Thu Jun 20 07:09:01 EST 2002

Thanks for all your swift replies.  I can't believe that I didn't even see
the obvious solution of checking to see if rsync was running before-hand.
I've essentially rolled up my call to rsync in a shell-script as below:

---begin script---


#is a previous rsync process still running?

ps -ef | grep 'rsync' | grep -v 'grep rsync' | grep -v '' >

if [ $? -eq 1 ]; then #rsync isn't running - let's launch it now
 rsync [opts] user at host::/module/* .
  echo "Rsync is still running...please wait and try again later"

---end script---

Thanks for all of your suggestions,

Matt Burgess

British Telecommunications plc
Registered office: 81 Newgate Street London EC1A 7AJ
Registered in England no. 1800000
This electronic message contains information from British Telecommunications
plc which may be privileged or confidential. The information is intended to
be for the use of the individual(s) or entity named above. If you are not
the intended recipient be aware that any disclosure, copying, distribution
or use of the contents of this information is prohibited. If you have
received this electronic message in error, please notify us by telephone or
email (to the numbers or address above) immediately.

-----Original Message-----
From: Adrian Ho [mailto:aho-sw-rsync at]
Sent: Thursday, June 20, 2002 14:19
To: rsync at
Subject: Re: cronning rsync

On Thu, Jun 20, 2002 at 12:51:14PM +0100, matthew.2.burgess at wrote:
> We're thinking about putting rsync to use in our production environment.
> What we want to do is have a cron job running on a client that replicates
> files on the host every five minutes.  We believe that some of the files
> will take longer than five minutes to complete.

Then you'll want to ensure that only one rsync instance is active
at a time.  This is best done with an external locking mechanism.
My personal favorite is setlock, part of Dan Bernstein's daemontools
package <>, and your setlock'd cron job
might look like this:

0-55/5 * * * * setlock -n /tmp/.rsync.lock rsync <blah blah blah>

Your OS may have similar functionality already available, and other
3rd-party packages may also have rolled their own equivalents (I know
both procmail and maildrop did) -- "man -k lock" to see for yourself.

- Adrian

To unsubscribe or change options:
Before posting, read:

More information about the rsync mailing list