Auto Restart MariaDB/MySQL If it Crashes on CentOS
Infrequently it happens on CentOS. MySQL/MariaDB stops working and our web application crashes. In this situation, we have to log in to SSH and restart MySQL/MariaDB server. It’s a painful thing.
To get rid of this issue, we can create a script to check database service is running or not. If the database service stops, the script will restart the service automatically.
Have a look at the bash script to restart MySQL:
restart_mysql.sh
Have a look at the bash script to restart MariaDB:
restart_mariadb.sh
After that add a cronjob like this:
That’s all. Using this method, you can restart any service. Thanks for reading. ?
Tags:
Linux