Script to restart MYSQL automatically when dropped?

0

I wonder if there is any script that will restart mysql if it crashes. I'm having some problems with mysql on my site and eventually it crashes, kind of 3 in 3 days it crashes, I've already adjusted the memory to optimize the system but I'd like to ensure the stability of the site with a script that reboots if it crashes.

I have seen that there is something like this in shared hosting but I do not know how to do it in the cloud. I have a digital ocean server with ubuntu server.

Thanks for the help.

    
asked by anonymous 06.05.2016 / 12:38

1 answer

1
#!/bin/bash
# mysql_check.sh
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
   sudo service mysql restart
fi
    
17.05.2016 / 05:14