Skip to content

Instantly share code, notes, and snippets.

@ryanneufeld
Created February 13, 2013 17:33
Show Gist options
  • Select an option

  • Save ryanneufeld/4946388 to your computer and use it in GitHub Desktop.

Select an option

Save ryanneufeld/4946388 to your computer and use it in GitHub Desktop.
#!/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