On Mon, 2008-03-31 at 11:43 +0200, Dag Wieers wrote: > Looking for an easy way to prevent a repetitive rsync to be running > multiple times, I was wondering if it could be useful to have an option > like: > > --pidfile /some/path/rsync-mirror-org.pid > > So that rsync can be run directly from cron without requiring a wrapper > script to do pidfile handling. > > This way rsync on startup could check the pid-file, see if another rsync > is using this pid, and bail out with an error if it is. Otherwise clean up > the stale pidfile and continue. > > I think this would be very useful to instruct mirrors how to configure it, > rather than providing some script that needs local customizations.
I'm not convinced that a pidfile is better implemented in rsync than in a wrapper script, which could be distributed in support/ of the source tree. If you don't care about actually having the pid in the file, you could use the flock(1) utility, which executes a command while holding a flock(2) lock on a specified file: flock --nonblock /some/path/rsync-mirror-org.lock rsync ... If the process goes away, the lock will too, so no manual cleanup of stale locks is needed. Matt -- To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html