Skip to content

Instantly share code, notes, and snippets.

@avleen
Created February 1, 2011 21:59
Show Gist options
  • Save avleen/806782 to your computer and use it in GitHub Desktop.
Save avleen/806782 to your computer and use it in GitHub Desktop.
LOCK=/tmp/shardbackup.lock
if [ -f $LOCK ]; then
ps -p `cat $LOCK` > /dev/null
if [ $? -eq 1 ]; then
# Stale lock file
rm $LOCK
else
echo "Lock file found for running process"
exit 1
fi
fi
# Create the lockfile
echo $$ > $LOCK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment