Skip to content

Instantly share code, notes, and snippets.

@arj03
Last active February 8, 2016 15:47
Show Gist options
  • Save arj03/8b8cbbcd4fea812e25ae to your computer and use it in GitHub Desktop.
Save arj03/8b8cbbcd4fea812e25ae to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -eq 0 ]; then
echo "\nUsage start-unless-running.sh process-name path-to-script\n"
exit 1
fi
ps aax | grep $1 | grep -v grep | grep -v start-unless-running.sh > /dev/null
if [ $? -eq 0 ]; then
echo "Process is running."
else
echo "Process is not running. Starting"
$2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment