On Thu, 10 Apr 2008, Dag Wieers wrote:

> 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
>>> 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.

>
> The flock utility is great. I learn something new everyday


Just noticed that the flock utility is fairly recent (since util-linux
2.13) which means that on most systems you do not have it.

For RHEL that means only available since RHEL5 :-(

That could be one of the reasons to have it as part of rsync (to
facilitate the distribution of a cron-job or simply make sure your mirrors
are using best practices without too much complexity).

--
-- dag wieers, dag@wieers.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