Create a file that root/sudo can access:
restart-mysql.sh:
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/sbin:/bin
if [[ "$(service mysql status)" != "running" ]]
then
service mysql start
fi
Make the file executable: chmod +x restart-mysql.sh
Then set to your crobtab to run the script every 5 minutes.
sudo crontab -e
First, add MAILTO="" to the top of the cron script. It will disable a lot of annoying emails. Or add your email if you prefer to receive an email when the script runs.
Then add to the bottom of the crontab script:
m h dom mon dow command
*/5 * * * * /path/to/restart-mysql.sh