[CentOS-mirror] ANN: withlock - reliable & easy locking for cron jobs

Randy McAnally rsm at fast-serv.com
Mon Feb 22 03:08:00 UTC 2010

This is what I use:



---------- Original Message -----------
From: Peter Pöml <poeml at cmdline.net>
To: centos-mirror at centos.org
Sent: Mon, 22 Feb 2010 03:52:11 +0100
Subject: [CentOS-mirror] ANN: withlock - reliable & easy locking for cron jobs

> Hi,
> [Apologies to those of you who received this mail more than once,
>  due to crossposting to different forums in order to reach most 
> relevant people]
> This is a one-time post to announce the creation of "withlock" - a 
> locking wrapper script to make sure that some program isn't run more 
> than once. It is ideal to prevent periodic jobs spawned by cron from 
> stacking up. The locks created are valid only while the wrapper is 
> running, and thus will *never* require additional cleanup, even 
> after a reboot. This makes the wrapper safe and easy to use, and 
> much better than implementing half-hearted locking within scripts.
> Usage is simple. Instead of your command
>     CMD ARGS...
> you simply use
>     withlock LOCKFILE CMD ARGS...
> If you are a mirror admin, there is a 99.9% chance that you might 
> want to use this locking wrapper. Likely you ran into the situation 
> where a script was (unexpectedly...) not finished before it was 
> started another time; and/or you actually hacked some kind of 
> locking into a script to prevent that from happening.
> Since I suffered the same situation for some years, I looked around 
> for solutions, and since I couldn't find one, I finally took the 
> time to create one. The resulting wrapper is used in production 
> since summer 2009, and proved to work reliably. Put the wrapper 
> around all your cron jobs and be happy :-)
> Use cases are to be found not only in mirroring, but that's where I 
> come from, so I know that this will be useful for you guys.
> Home page: http://code.google.com/p/withlock/
> Features:
>    - locks that never need a cleanup, whatever happens
>    - can wait a defined time for a lock to become "free"
>    - disallows lock files in unsafe locations (to prevent symlink 
> attacks)   - easily installed (it's just one file), highly portable
> Requirements:
>    - Python 2.4 or newer
>    - lots of platforms are supported (see list on home page)
> For more information, please come to 
> http://code.google.com/p/withlock/ .
> Thanks,
> Peter
> _______________________________________________
> CentOS-mirror mailing list
> CentOS-mirror at centos.org
> http://lists.centos.org/mailman/listinfo/centos-mirror
------- End of Original Message -------

More information about the CentOS-mirror mailing list