Skip to content

Instantly share code, notes, and snippets.

@alpsayin
Created June 17, 2015 17:44
Show Gist options
  • Save alpsayin/f67316d11613b6db92d2 to your computer and use it in GitHub Desktop.
Save alpsayin/f67316d11613b6db92d2 to your computer and use it in GitHub Desktop.
Shell Script to check if a process is running and do actions accordingly
# Alp Sayin
# 17/06/2015
#!/bin/bash
os=`uname`
while true
do
result=`ps aux | grep "tomcat6" | grep -v grep | grep -v "checkit.sh"`
# echo $result
if [ -z "$result" ];
then
if [ "Linux" == $os ];
then
sudo service tomcat6 start
sleep "$2"
fi
if [ "Darwin" == $os ];
then
sudo service tomcat6 start
sleep "$2"
killall afplay
fi
fi
sleep "$1"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment