I'm using a MySQL database and Apache server with an AWS EC2 instance running AWS Linux. I start them both using the service command, but I am not familiar with any other tool that would come pre-installed or available through package manager that would ensure they don't get interrupted.

Now I'm just running a script manually that restarts all the services when an issue with the site occurs:

sudo service httpd restart && sudo service php-fpm-5.6 restart && sudo service mysqld restart

Sometimes the services run into and error and hang or otherwise get interrupted and it also crashes my site. I'm looking for a way to restart the services and monitor their health either through a command line utility, modifying config files, or any other way that works.

  • your question is too generic. Which service runs into an error, and why? How do you detect it? What happens?
    – sivann
    Oct 24, 2015 at 15:15
  • the most common example that mysql stops running and when it happens my site doesn't load properly, i will look at the mysql error log to find any specific example. but i'm looking for a generic solution anyway - if a process is not running an attempt should be made to start it, no matter the specific cause why it stopped. Oct 24, 2015 at 15:19
  • you mean the process dies? Or that it apache tries to open more db connections than mysql is configured to serve? If it's just stuck what does "mysqladmin processlist" report? monit is a software that can restart failed services, but I really doubt that mysql or apache just die, I've never seen that in 20 years. Also check dmesg to check if the OS kills processes due to lack of memory (OOM kill).
    – sivann
    Oct 24, 2015 at 15:23
  • again, it's not for any specific case, i'm trying to ensure very high reliability for my site without having to check manually. in my case they were not running mostly due to: error in config file or module, system reboot Oct 24, 2015 at 15:50
  • 1
    It's the default Amazon Linux, which is based on Red Hat Enterprise Linux and later linux-xen-kernel. Oct 24, 2015 at 16:40

1 Answer 1


For generic checks of a service I see 2 main options:

  1. a process monitor like monit (AmiLinux has monit in its amzn-main repo)
  2. monitor multiple aspects of your system performance with zabbix which can also perform conditional command execution on top of metric trigger notifications. This should ideally run on another server and monitor your server through an agent to allow for better reliability.
  • Thanks, good examples I didn't know exist, I couldn't find them pre-installed. I will look for an online resource explaining their usage. Oct 24, 2015 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.