Skip to content

Instantly share code, notes, and snippets.

@neotyk
Created February 22, 2010 22:53
Show Gist options
  • Save neotyk/311623 to your computer and use it in GitHub Desktop.
Save neotyk/311623 to your computer and use it in GitHub Desktop.
#!/bin/bash
pidfile=$WHERE_YOUR_PIDFILE_IS_LOCATED
if [ -e $pidfile ]; then
pid=`cat $pidfile`
if kill -0 >/dev/null 2>&1 $pid; then
echo "Already running"
exit 1
else
rm $pidfile
fi
fi
echo $$ > $pidfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment