Created
March 5, 2019 04:08
-
-
Save huanyichuang/7d96291efa8c6c4996c6b9df591b3e23 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Program: | |
# Check if mysql is down, if down, turn it on. | |
# History: | |
# 2019/02/25 First Release by Eric | |
# 2019/03/05 Echo date time in logs for better readability. | |
UP=$(service mysql status|grep 'running' | wc -l); | |
now=$(date); | |
if [ "$UP" -ne 1 ]; | |
then | |
echo "$now MySQL is down."; | |
sudo service mysql start | |
else | |
echo "$now All is well."; | |
printf "%s Log test" "$now" >> ./log | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment