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 Mon, 2008-03-31 at 11:43 +0200, Dag Wieers wrote: > Looking for an easy way to prevent ...


Go Back   Usenet Forums > Networking and Network Related > Rsync

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

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB 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 08:47 PM.


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