This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Monitoring running services and restart them if they stop working on Ubuntu.
#1
Monitoring running services and restart them if they stop working on Ubuntu.
To monitor running services and restart them if they stop working you can use Monit.

Here is the guide to install it:
https://www.digitalocean.com/community/t...gure-monit

But for a basic install run:

Code:
apt-get install monit

My setup:

Code:
nano /etc/monit/monitrc

And edit:

Code:
set httpd port 2812
    use address 12.34.56.789 or monit.YourDomain.com # only accept connection from localhost
    allow 0.0.0.0/0.0.0.0        # allow localhost to connect to the server and
    allow admin:*password*      # require user 'admin' with password 'monit'

And add this to the bottom of the file.

Code:
#Apache Monitor
check process apache with pidfile /var/run/apache2/apache2.pid
    start program = "/etc/init.d/apache2 start" with timeout 60 seconds
    stop program  = "/etc/init.d/apache2 stop"
    if failed host YourDomain.com port 80 protocol http then restart

#MySQL Monitor
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
    start program = "/etc/init.d/mysql start"
    stop program = "/etc/init.d/mysql stop"
    if failed unixsocket /run/mysqld/mysqld.sock then restart

Code:
service monit restart

Here is an example of Monit restarting Apache when it went down 7hrs ago.

   
Reply
Thanks given by:
#2
RE: Monitoring running services and restart them if they stop working on Ubuntu.
I can not over state how well this has worked for me.
Reply
Thanks given by:


Possibly Related Threads...
Thread Author Replies Views Last Post
Upgrade to Ubuntu 16.04 from 14.04 HogensHero 7 10,078 10-04-2019, 11:20 AM
Last Post: type-00
Ubuntu: How to setup TLS on postfix and dovecot Diablo925 28 59,638 02-15-2018, 08:46 PM
Last Post: duane
Ubuntu 14.04 sessions not clearing fix TGates 4 8,180 05-07-2017, 03:42 PM
Last Post: TGates

Forum Jump:


Users browsing this thread: 1 Guest(s)