Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

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?
0
er2er
Asked:
er2er
  • 2
  • 2
2 Solutions
 
mikemsdCommented:
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
 
evilrixSenior 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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now