Hi guys, often happen, that whenever MySQL suddenly turns off, my WordPress crashes it causing downtime. If I go home, I have to wait anywhere from a few hours to a few days until I go back home and log in to my computer and restart my server using manual means.
I am aware that SSH can be installed on my smartphone and I can log in through it and restart my server.
But shouldn’t MySQL restart by itself when it crashes? Sure not, but is there another easy way that can be done to restart automatically every time it goes down? let’s take a look at the tutorial.
Step by Step automatically restart MYSQL in aapanel
- Open your aapanel dashboard
- Go to the cron section
- Add CronJob
- In Type of Task select Shell Script
- Execution cycle 5-10 minutes
- Fill Script content:
#!/bin/bash
# Check if MySQL is running
sudo service mysql status > /dev/null 2>&1# Restart the MySQL service if it’s not running.
if [ $? != 0 ]; then
/bin/systemctl restart mysql.service
fi
Note:
To test, turn off MySQL, try turning on the script by selecting execute
I’m using Centos OS on my server
If you have difficulty practicing it, write in the comments section the problem you encountered.
Read More: How Migrate AAPanel using One-Click Migration API version 3.0