Hi guys,
Last time I had some issues with MySQL server on my VPS. I fixed them but just in case I wrote a small bash script to check the MySQL status, if it’s down to start it.
You have to run this script using a cron job.
Create a scheduled cron job via Webmin-> Scheduled Cron Jobs->Create a new scheduled cron job
#!/bin/bash
systemctl status mysql.service | grep "stopped\|dead"
if [ $? -eq 0 ]; then
systemctl start mysql.service
fi
If any service is dying seemingly randomly, you should find the root cause and fix it.
Edit: This is especially true of a database, which can become corrupt and lose data if it is being improperly shut down for some reason (OOM killer, perhaps?).