Kill automatically process which uses over 90% CPU

Asked by Oier Mees on 2011-06-05

Is there a way to automatically kill processes which make the system unusable because they are using over %90 CPu or x of memeory? Sometimes it is not possible to change to a fresh tty to kill it manually and new users will certainly not know ho to do it.

Question information

English Edit question
Ubuntu gnome-system-monitor Edit question
No assignee Edit question
Last query:
Last reply:
mycae (mycae) said : #1

Unfortunately, automatic detection of runaway processes is very very tricky. It is very easy to accidentally kill a process that is not runaway, but actually needs to do a solid bit of work or use some CPU. You can't tell, as that requires solving an impossible problem, known as the "halting problem".

It is possible to set up a small script that monitors CPU usage and ram usage over time, but this will only work for some people, not all. If I do video work, or some 3D work, I will certainly use up most of my RAM during the encode stage, whilst maxing out CPU

Basically the best runaway processes detector is the user saying "This is no longer worthwhile for me to wait."

You can use the "xkill" tool, by binding it to a keyboard shortcut, if the process has an X window. Your cursor will turn to a little "x" which will kill the process that owns the windows when you left click.

Oier Mees (oier) said : #3

What I say is that there should be a cron job for example checking the processes and ask the user if they want to kill a certain process if it detects that it is using a extraordinary high load of cpu or ram. That way you avoid killing the wrong apps. I would like to have a similar fetured integrated to the system so newbies don't have to worry of knowing xkill or the kill commands.
Is this feasible?

Oier Mees (oier) said : #4

but I think that the best solution would be to use or modify the kernel scheduler, right? maybe using Cgroups?

Can you help with this problem?

Provide an answer of your own, or ask Oier Mees for more information if necessary.

To post a message you must log in.