Last active
December 11, 2015 19:51
-
-
Save arnaldopereira/8690440deeb9175df17c to your computer and use it in GitHub Desktop.
lockfile-utils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOCKFILE="/tmp/foo.lock" | |
function atexit { | |
lockfile-remove $LOCKFILE | |
echo atexit! | |
exit | |
} | |
lockfile-create --retry 0 --use-pid $LOCKFILE || exit | |
# command here | |
sleep 10 | |
trap atexit EXIT HUP INT TERM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment