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?

link|improve this question
feedback

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
link|improve this answer
feedback

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.

link|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
feedback

Your Answer

 
or
required, but never shown