Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I use monit to make sure everything running fine, but monit daemon was also stopped.

I dont know how this be, and how to prevent monit daemon from stopped?

share|improve this question

2 Answers

On Ubuntu 9.10, /etc/inittab does not exist, because Ubuntu uses upstart instead of /sbin/init. So to achieve the same thing as answer #1 above we need an upstart script:

# This is an event.d (upstart) script to keep monit running
# To install disable the old way of doing things:
#
#   /etc/init.d/monit stop && update-rc.d -f monit remove
#
# then put this script here: /etc/init/monit.conf
#
# You can manually start and stop monit like this:
# 
# start monit
# stop monit
#
# Karim Ratib (http://thereisamoduleforthat.com)
# 
# Based on monit.upstart (https://code.google.com/p/monit/source/browse/trunk/contrib/monit.upstart?r=132)
# by Michael Hale (http://halethegeek.com)

start on runlevel [2345]
stop on runlevel [06]

exec /usr/sbin/monit -Ic /etc/monit/monitrc
respawn
share|improve this answer
Just FYI, Redhat (and so Centos) have started using Upstart instead of inittab in the latest linux versions. So this may work there too. – mixdev Oct 21 '12 at 22:49
On Redhats, this will work mmonit.com/wiki/Monit/Upstart – mixdev Oct 21 '12 at 23:08

The best option I can think of for something that absolutely has to be run and must be restarted if it happens to die is to run the process out of init.

You put an entry like the following in /etc/inittab:

name:234:respawn:/usr/local/bin/daemon

Then restart init with:

init q

Now anytime your daemon dies, it will automatically be "respawned"

Edit: I am not familiar with Monit, but I happened to check their FAQ page, and they have detailed this specifically for monit.

share|improve this answer
I am familiar with Monit and concur with this answer. – Brian De Smet Jan 25 '10 at 0:02
I already done this several days ago.. and monit daemon stopped some hours ago... but is the number "234" above is PID? thanks – Kewasen Jan 25 '10 at 1:51
234 are the runlevels in which the process should run. You may need to add a 5 to that if you are running on a system that boots directly to an X-based login. – Alex Jan 25 '10 at 3:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.