Created
February 13, 2013 17:33
-
-
Save ryanneufeld/4946388 to your computer and use it in GitHub Desktop.
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 | |
| self="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" | |
| if [ -r "/tmp/${self}.pid" ]; then | |
| pid=`cat /tmp/${self}.pid` | |
| echo "Looks like the minifier is already running with pid=$pid!"; | |
| echo "Checking to see if PID $pid is still running..."; | |
| if [ -d "/proc/$pid" ]; then | |
| echo "Yup, it's really running according to /proc/$pid!" | |
| exit 0; | |
| else | |
| echo "Doesn't look like it's running, replacing pid=$pid with pid=$$." | |
| fi | |
| fi | |
| echo $$ > /tmp/${self}.pid | |
| # code goes here | |
| rm /tmp/${0}.pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment