This Bash script is used for monitoring services on a server and restarting them if they are not running. It is especially useful when critical services such as databases or web servers must run uninterrupted.
Copy the contents of the check_crash.sh file to a new file on your server, for example /opt/check_crash.sh.
sudo chmod +x /opt/check_crash.sh
sudo crontab -e
*/5 * * * * /opt/check_crash.sh > /dev/null 2>&1
The script checks the status of multiple services, including MySQL, Nginx, Apache2, and PHP-FPM. You can customize it to your specific needs by adding or removing the services to be checked.
S. Volkan Kücükbudak