Automatically start MySQL if apache kills the process or sacrifice children on Ubuntu Server

There are several ways to solve the problem of Apache running wild and killing MySQL. It the problem occurs very infrequently, there’s a easy way of restarting MySQL with the use of the crontab. The script even sends a notification email so you know what just happened.

First, SSH into your server:

Create a script file:

Paste the following:

Press CTRL + O to save, and CTRL + X to exit.

Give execute permission to your script:

Edit the Crontab:

Paste the following:

Press CTRL + O to save, and CTRL + X to exit.

To see if it works, type the following:

In case the service doesn’t start, just start it manually with the following: