Skip to content

Instantly share code, notes, and snippets.

@merevu
Created August 31, 2015 07:33
Show Gist options
  • Save merevu/c8cdf6c21defe8710fe9 to your computer and use it in GitHub Desktop.
Save merevu/c8cdf6c21defe8710fe9 to your computer and use it in GitHub Desktop.
bash script :: avoid self-process dup-running
#!/bin/bash
if [[ "`pidof -x $(basename $0) -o %PPID`" ]]; then
echo "This script is already running with PID `pidof -x $(basename $0) -o %PPID`"
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment