Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any generic way to monitor a process and restart it automatically if it's pegged at 100% CPU for over x seconds?

I'm battling some bugs in Mono's fastcgi server and while I search for a fix (analyzing stack traces) I'm looking for a workaround that will automatically detect it being stuck and restart it with the same command line parameters.


share|improve this question

1 Answer 1

up vote 1 down vote accepted


Sample configuration:

check process example-server with pidfile /var/run/example-server.pid
  start program = "/etc/init.d/example-server start" with timeout 60 seconds
  stop program  = "/etc/init.d/example-server stop"
  if cpu > 90% for 3 cycles then restart

See Also:

  1. http://serverfault.com/questions/97541/kill-process-with-high-cpu-usage-after-x-time
  2. http://stackoverflow.com/questions/2784468/monitor-and-kill-runaway-processes-using-100-io
  3. http://mmonit.com/monit/documentation/monit.html
share|improve this answer
Thanks, that looks promising. Worst case scenario was to write a light wrapper around pidstat, but this looks good. –  Mahmoud Al-Qudsi May 11 '12 at 3:01

Your Answer


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.