Script to restart MYSQL automatically when falling?

Asked

Viewed 383 times

0

I wonder if there is a script that restarts mysql if it falls. I am having some problems with mysql on my site and eventually it falls, type 3 in 3 days falls, I have already adjusted the memory to optimize the system but I would like to ensure the stability of the site with a script that restarts if it falls.

I’ve seen that there is something like this in shared hosting but I don’t know how to do it in the cloud. I have an Ocean digital server with Ubuntu server.

I appreciate the help.

  • 1

    However I think it is better to come to the conclusion of why to fall.. This may give data consistency problems...

1 answer

1

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.