Created
February 9, 2016 16:23
-
-
Save afelicioni/33b5b35e768693b34417 to your computer and use it in GitHub Desktop.
lock test
This file contains 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
lockdir=/var/tmp/it_totalizer_chiamate | |
pidfile=/var/tmp/it_totalizer_chiamate/pid | |
if ( mkdir ${lockdir} ) 2> /dev/null; then | |
echo $$ > $pidfile | |
trap 'rm -rf "$lockdir"; exit $?' INT TERM EXIT | |
sleep 10 | |
rm -rf "$lockdir" | |
trap - INT TERM EXIT | |
else | |
echo "Lock Exists: $lockdir owned by $(cat $pidfile)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment