This is a discussion on Re: RFE: Lockfile option for use in cronjobs - Tools ; On Wed, 2 Apr 2008, Matt McCutchen wrote: > 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 ...
On Wed, 2 Apr 2008, Matt McCutchen wrote:
> 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
>> --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.
The flock utility is great. I learn something new everyday
Thanks a lot !
-- dag wieers, email@example.com, http://dag.wieers.com/ --
[Any errors in spelling, tact or fact are transmission errors]
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html