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

From: Calvin Morrison <mutantturkey_AT_gmail.com>
Date: Tue, 8 Apr 2014 11:48:17 -0400

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: https://github.com/mutantturkey/lock

Cheers,
Calvin
Received on Tue Apr 08 2014 - 17:48:17 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 08 2014 - 18:00:11 CEST