cronning rsync

matthew.2.burgess at bt.com matthew.2.burgess at bt.com
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---

#!/bin/sh

#is a previous rsync process still running?

ps -ef | grep 'rsync' | grep -v 'grep rsync' | grep -v 'rsync.sh' >
/dev/null

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

---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 03s.net]
Sent: Thursday, June 20, 2002 14:19
To: rsync at lists.samba.org
Subject: Re: cronning rsync


On Thu, Jun 20, 2002 at 12:51:14PM +0100, matthew.2.burgess at bt.com 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 <http://cr.yp.to/daemontools.html>, 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:
http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html




More information about the rsync mailing list