Creating a self hosted WordPress Droplet in DigitalOcean is really convenient but maintaining it can be a nightmare. If you don't connect it to CloudFlare your website will most likely crushed by brute force traffic.
Even if you have tamed the malicious traffic, spikes will still occur from time to time and you'll need to resart MySQL. Sure you can easily login from your smartphone and restart but it's better if you don't have to do it at all.
So I searched the Internet and found this little script to automate it
Open the crontab editor (I've chosen VIM) in the terminal with
crontab -e and add the following line:
* * * * * service mysql status > /dev/null || service mysql start
This will instruct the server to check mySQL status and it will restart if there's any abnormal status.
Credit to Matthias Hagemann