Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shell script to restart MySQL automatically when it shuts down
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
echo "MySQL is down.";
sudo service mysql start

This comment has been minimized.

Copy link
Owner Author

@Nikschavan Nikschavan commented Dec 20, 2016

Download the script with wget


Make the script executable

sudo chmod +x

Execute this script each minute with a crontab

sudo crontab -e

*/1 * * * * sh /path/to/script/

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