Last active
December 29, 2015 14:19
-
-
Save typomedia/7683565 to your computer and use it in GitHub Desktop.
MySQL Auto Restart Script
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/sh | |
# Copyright 2013 Typomedia Foundation. All rights reserved. | |
# Released under GPL version 3. | |
# | |
# MySQL Auto Restart Script v1.0 | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
DBHOST=localhost | |
DBUSER=root | |
PASSWORD=******** | |
mysqladmin --user=$DBUSER --password=$PASSWORD ping | grep 'mysqld is alive' > /dev/null 2>&1 | |
if [ $? != 0 ] | |
then | |
service mysql stop | |
sleep 1 | |
service mysql start | |
echo `date` | mailx -s 'MySQL Daemon restartet' admin@domain.tld | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run cron every 5 minutes
*/5 * * * * /etc/default/restart.mysql.sh