Quantcast
Channel: April 2017 - Nikhil Chavan
Viewing all articles
Browse latest Browse all 2

Shell script to restart MySQL automatically when it shuts down.

$
0
0

A dirty hack but essential at times, the MySQL server consumes higher memory if not configured correctly and due to this the MySQL service is terminated by the OS to save itself from crashing under high traffic.

A simple shell script can be used to restart the MySQL service when it is terminated.

View the code on Gist.

Download this script using wget

wget https://gist.githubusercontent.com/Nikschavan/2346941b328b2c7f08b79611b2c9157c/raw/75ccc4855a2e8955d1c9ffac430857704f8c15f4/mysql-monitor.sh

Make the script executable

sudo chmod +x mysql-monitor.sh

Execute this script each minute with a crontab

sudo crontab -e
*/1 * * * * sh /path/to/script/mysql-monitor.sh

The post Shell script to restart MySQL automatically when it shuts down. appeared first on Nikhil Chavan.


Viewing all articles
Browse latest Browse all 2

Trending Articles