Created
December 30, 2013 16:57
-
-
Save drzippie/8184696 to your computer and use it in GitHub Desktop.
Check shellscript - check is running
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 | |
| # | |
| lockdir=/tmp/diario_stocks.lock | |
| if mkdir "$lockdir" | |
| then | |
| echo >&2 "successfully acquired lock" | |
| # Remove lockdir when the script finishes, or when it receives a signal | |
| trap 'rm -rf "$lockdir"' 0 # remove directory when script finishes | |
| # Optionally create temporary files in this directory, because | |
| # they will be removed automatically: | |
| # tmpfile=$lockdir/filelist | |
| else | |
| echo >&2 "cannot acquire lock, giving up on $lockdir" | |
| exit 0 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment