Created
October 17, 2015 09:49
-
-
Save clarinet758/fc1c948dd5dd55bb845f 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
| #!/bin/bash | |
| target=ntpd | |
| logfile=/var/log/origin.log | |
| function timestamp() { | |
| echo "`date '+%y/%m/%d %H:%M:%S'`" | |
| return $? | |
| } | |
| #echo `timestamp` | |
| #ps -C $chk -o comm= > /dev/null || sudo /usr/sbin/$chk | |
| function res() { | |
| echo `ps -C $target -o comm= | head -n 1` | |
| return $? | |
| } | |
| if [ ${target} = "`res`" ]; then | |
| echo "`timestamp` [$target] status is running" >> $logfile | |
| exit 0 | |
| else | |
| echo "`timestamp` [$target] status is error" >> $logfile | |
| echo "`timestamp` [$target] trying start" >> $logfile | |
| service $target start | |
| fi | |
| if [ ${target} = "`res`" ]; then | |
| echo "`timestamp` [$target] status is running" >> $logfile | |
| exit 0 | |
| else | |
| echo "`timestamp` [$target] start failed(unknown error)" >> $logfile | |
| #mail.... | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment