How to automaticaly kill long-lasting processes under Linux?

I'd like to limit the allowed "CPU running time time" for particular applications running on the Linux server.
For instance, renice a PHP script (CGI mode, webhosting environment, PHP under user privileges, executed through Apache) after 1 minute and kill this script if it runs longer than 5 minutes.
Ulimit-based solution is insufficient. SPRI-based solution can only do the first part of such job.

I expect that the best solution would be a bash script executed from a cron job.
What script can perform such tasks?
er2erAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mikemsdConnect With a Mentor Commented:
The program I have used before is AND the Auto Nice Daemon. It can automatically renice processes that have been using too much CPU, and kill off certain ones after a period of time. You can specify by process name which ones you want to nice or kill in it's config file.

http://and.sourceforge.net/
0
 
er2erAuthor Commented:
Thank you for this information.
I'm going to check this daemon out and report on this tomorrow (CET).
0
 
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
This should do exactly what you need: -

http://www.psmon.co.uk/
0
 
er2erAuthor Commented:
Thank you - I found the AND a better solution, as it combines "nice" with "kill" action.
I appreciate the help of both of you.
0
 
evilrixSenior Software Engineer (Avast)Commented:
Very welcome... I shall tell Nicola (the author of psmon) your reason for not choosing it -- I'm sure she'll look at adding the support you want :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.