Created
March 3, 2013 21:01
-
-
Save agazso/5078270 to your computer and use it in GitHub Desktop.
Run commands protected by lock
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/sh | |
| LOCKFILE=/tmp/meeting_dashboard.lock | |
| COMMAND="$*" | |
| [ "$1" = "" ] && (echo usage $0 command; exit 1) | |
| # Previous run should execute successfully: | |
| [ -f $LOCKFILE ] && exit 0 | |
| # Upon exit, remove lockfile. | |
| cleanup() | |
| { | |
| rm -f $LOCKFILE | |
| exit $? | |
| } | |
| trap cleanup EXIT SIGINT | |
| touch $LOCKFILE | |
| $COMMAND | |
| exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment