Skip to content

Instantly share code, notes, and snippets.

@arnaldopereira
Last active December 11, 2015 19:51
Show Gist options
  • Save arnaldopereira/8690440deeb9175df17c to your computer and use it in GitHub Desktop.
Save arnaldopereira/8690440deeb9175df17c to your computer and use it in GitHub Desktop.
lockfile-utils
#!/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