Last active
February 28, 2017 23:46
-
-
Save jmillerdesign/ce2bcb41ef0630be9fd3 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 | |
PATH=/usr/sbin:/usr/bin:/sbin:/bin | |
if [[ $(service mysql status | grep running | wc -l) != 1 ]]; | |
then | |
echo "$(date "+%Y-%m-%d %T")" >> /root/keep-mysql-running.log | |
echo "$(service mysql status)" >> /root/keep-mysql-running.log | |
service mysql start >> /root/keep-mysql-running.log | |
fi | |
---------------------------------------------------------------------- | |
#!/bin/bash | |
PATH=/usr/sbin:/usr/bin:/sbin:/bin | |
if [[ $(ps -ef | grep "/usr/sbin/mysqld" | grep -v "grep" | wc -l) != 1 ]]; | |
then | |
echo "$(date "+%Y-%m-%d %T")" >> /root/keep-mysql-running.log | |
echo "$(service mysql status)" >> /root/keep-mysql-running.log | |
service mysql restart >> /root/keep-mysql-running.log | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this on a cron job to start mysql if it ever detects it as not running: