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.

OK, so I'm familiar with several methods of implementing a "watchdog" script. The problem is, that none of these check for a "hung" or unresponsive process. They all just check if the process is still present. Perhaps I'm showing my lack of programing knowledge, but I'm under the impression, a process can sometimes continue to appear running to this system but in fact be crashed/hung. Is there a way to detect this condition and trigger (pkill blah && blah) the process in question?

Some examples of what I'm NOT looking for:

http://blog.eracc.com/2010/05/08/linux-monitor-a-service-with-a-watchdog-script/ http://community.webfaction.com/questions/6157/watchdog-script-to-keep-process-running-with-cron linux + create simple watch dog process in shell script Monitoring a one-off service

cron this:

#!/bin/sh
if [ ` pgrep processname -c` -le "0" ]; then processname
share|improve this question

closed as not a real question by John Gardeniers, Khaled, Dave M, EEAA, Shane Madden Feb 9 '13 at 20:13

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

Look into the Monit or M/Mmonit utility.

Its uses are covered well here on Server Fault, as well as in the documentation examples.

You can check process by PID or presence easily; but additional parameters like CPU utilization or RAM consumption can also be triggers for a variety of actions.

share|improve this answer
1  
This is probably the best "universal" way of doing it, I've rarely found something that "hung" without taking up as many CPU cycles as possible. The only "right" way of doing it is to see whether the process is doing the work it's supposed to be doing, which has to be tailored to the individual process. –  DerfK Feb 8 '13 at 23:43

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