Re: RFE: Lockfile option for use in cronjobs

This is a discussion on Re: RFE: Lockfile option for use in cronjobs within the Rsync forums, part of the Networking and Network Related category; On Wed, 2 Apr 2008, Matt McCutchen wrote: > On Mon, 2008-03-31 at 11:43 +0200, Dag Wieers ...


Go Back   Usenet Forums > Networking and Network Related > Rsync

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008
Dag Wieers
 
Posts: n/a
Default Re: RFE: Lockfile option for use in cronjobs

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 :)

Thanks a lot !
--
-- 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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:23 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0