Limit the CPU usage of a certain application in Linux
You can do this by installing cpulimit. You can limit a certain running application either by name or by process ID:
cpulimit -e firefox -l 30
This won’t let Firefox go beyond a 30% CPU usage limit.
If you’d rather go by process, you can do it like this:
cpulimit -p 3493 -l 40
This will limit process number 3493 to 40% CPU consumption.



Awesome tool! Thanks!
Do you have any ideas for limiting the memory usage of a process?
CPUlimit is in the Ubuntu repositories.
sudo apt-get install cpulimit
This is exactly what i was looking for, thanks.
@ James: yes, according to this reply in comp.os.linux.misc there should be an option to limit memory using getrlimit.
For the Ubuntu users: This util apparently is contained in the package libbsd-resource-perl (according to apt-cache: perl BSD::Resource - BSD process resource limit and priority).
cu, w0lf.
You never give credits when you find a story on some small blog? I’ll be waiting around the corner…!
@name: …aaaaand by that you mean?
@name: vad ca ai IP de Bucuresti
Pai uite: scris de mine in 15 octombrie 2007: http://mylro.org/content/view/42/52/
Lucram cu cpulimit de vreo 5-6 ani cand am scris postul de mai sus, asa ca chill
PS: mi-a placut faza cu “te astept dupa colt” :))
(James comment): If you limit the process memory, one of 2 happens: programs ends because of lack of memory with a crash, or if supported, a error message.
@Jorge: that depends on how much memory the application is using. If it doesn’t pass that maximum required by the application being limited, then all should be fine. If it does pass that certain limit, then yes, one of the two things you mentioned will happen.