Skip to content

Instantly share code, notes, and snippets.

@paralleltree
Created January 12, 2015 01:41
Show Gist options
  • Save paralleltree/dafd431673645262f7b2 to your computer and use it in GitHub Desktop.
Save paralleltree/dafd431673645262f7b2 to your computer and use it in GitHub Desktop.
# !/bin/sh
readonly target="target_name" # "abc.rb"
readonly execute="execution_command" # "ruby abc.rb &" or "ruby ${target} &"
while true
do
proc=$(ps -ef | grep ${target} | grep -v grep | wc -l)
if [ ${proc} = 0 ]; then
echo "Target process was terminated!!"
${execute}
fi
sleep 1m
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment