Created
June 17, 2015 17:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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