Skip to content

Instantly share code, notes, and snippets.

@typomedia
Last active December 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typomedia/7683565 to your computer and use it in GitHub Desktop.
Save typomedia/7683565 to your computer and use it in GitHub Desktop.
MySQL Auto Restart Script
#!/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
@typomedia
Copy link
Author

Run cron every 5 minutes
*/5 * * * * /etc/default/restart.mysql.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment