Re: [dev] lock (1) - a dead simple lock script

From: Amadeus Folego <>
Date: Tue, 8 Apr 2014 13:19:45 -0300

Hi Calvin,

Thanks for sharing it, it's really neat!

I have the same problem with some cron jobs, but I use lockrun[1].

It's source code is quite simple[2] too.

The reason why I would still stick with lockrun is that
in the context of cron jobs, it is better that the task does not
runs than piling up.

What do you think about it?


On Tue, Apr 08, 2014 at 11:48:17AM -0400, Calvin Morrison wrote:
> Hi,
> I've just written lock, a simple little script to ensure that two
> programs won't run at once. I am using this to ensure my users don't
> overwrite the same shared folder in a set of genomic analysis scripts.
> I thought it might be useful.
> The script will either create the lock and exit, or ping the lock
> every two seconds until the lock is gone (via rmdir). I chose
> directories as lock because they are atomic on Linux, so that avoids
> some issue of locks overriding eachother.
> Usage is pretty simple, if you were to spawn this script twice, only
> one do_work would execute at a time.
> lock mylock
> do_work
> sleep 10
> rmdir mylock
> This time I won't forget my link:
> Cheers,
> Calvin
Received on Tue Apr 08 2014 - 18:19:45 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 08 2014 - 18:24:06 CEST