Skip to content

Instantly share code, notes, and snippets.

@danish-rehman
Created October 19, 2012 07:28
Show Gist options
  • Save danish-rehman/3916721 to your computer and use it in GitHub Desktop.
Save danish-rehman/3916721 to your computer and use it in GitHub Desktop.
Script watch
#!/bin/bash
# find if Apache (httpd) running or not
service_list=('application_errormonitor.py' 'controller_errormonitor.py')
COUNTER=0
for service in ${service_list[@]}
do
echo "----------------"
if ps ax | grep -v grep | grep $service > /dev/null; then
echo "$service service running, everything is fine"
else
echo "$service is not running"
if [ $COUNTER == 0 ]; then
nohup python /home/application_errormonitor.py &
elif [ $COUNTER == 1 ]; then
nohup python /home/controller_errormonitor.py &
fi
echo "$service started"
fi
echo "----------------"
let COUNTER=COUNTER+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment