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