Skip to content

Instantly share code, notes, and snippets.

@huanyichuang
Created March 5, 2019 04:08
Show Gist options
  • Save huanyichuang/7d96291efa8c6c4996c6b9df591b3e23 to your computer and use it in GitHub Desktop.
Save huanyichuang/7d96291efa8c6c4996c6b9df591b3e23 to your computer and use it in GitHub Desktop.
#!/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