Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a micro instance of ec2. A couple of java process’ gets killed every now and then.

Which tool can I run to monitor process and restart then when they get killed?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I don't think calling a pipeline of a few programs from a cron-job is the lightest way to monitor a service. The lightest way, in my opinion, is to use the init process to supervise your processes. Unfortunately the most popular /sbin/init implementation (SysVinit) cannot do that well. Upstart is much better at this task, systemd probably too.

An alternative is a non-init process supervisor like the supervise from daemontools package and its clones. Such supervisor is started once, runs the supervised process and reacts only when something happens to it (like it crashes). So it uses virtually no extra resources and reacts immediately to crashes.

share|improve this answer
2  
It's daemontools, and some of the alternatives that you allude to include runsv from Gerrit Pape's runit package. –  JdeBP Jun 18 '11 at 10:18
    
There's also monit, which I've used and seems to work well. I've used this on ARM and it works well. –  tjameson Jun 18 '11 at 20:13
add comment

The lightest weight way would be just to have a cron job that runs every now and then, and starts the program if it's not already running. In most cases, a simple grep of ps will tell you if it's running:

( ps x | grep $PROGRAM NAME | grep -v grep ) || /path/to/program
share|improve this answer
add comment

Your Answer

 
discard

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

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