Created
March 28, 2018 17:37
-
-
Save manickamk/c4415c48b5b6689811e9db258827d487 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# cat /root/service.sh | |
################################################################ | |
#!/bin/bash | |
###edit the following | |
service=searchd | |
[email protected] | |
###stop editing | |
host=`hostname -f` | |
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 )) | |
then | |
date +\%Y\-%m\-%d\ %H\:%M\:%S | |
echo "$service is running" | |
else | |
/etc/init.d/rc.searchd start | |
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 )) | |
then | |
subject="$service at $host has been started" | |
echo "$service at $host wasn't running and has been started" | mail -s "$subject" $email | |
else | |
subject="$service at $host is not running" | |
echo "$service at $host is stopped and cannot be started!!!" | mail -s "$subject" $email | |
fi | |
fi | |
[root@host01 ~]# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment