Limit the CPU usage of an application (process) – cpulimit
cpulimit is a simple program that attempts to limit the cpu usage of a process (expressed in percentage, not in cpu time). This is useful to control batch jobs, when you don’t want them to eat too much cpu. It does not act on the nice value or other scheduling priority stuff, but on the real cpu usage. Also, it is able to adapt itself to the overall system load, dynamically and quickly.
Installation:
Download last stable version of cpulimit
Then extract the source and compile with make:
tar zxf cpulimit-xxx.tar.gz
cd cpulimit-xxx
make
Executable file name is cpulimit. You may want to copy it in /usr/bin.
Usage:
Limit the process ‘bigloop’ by executable name to 40% CPU:
cpulimit –exe bigloop –limit 40
cpulimit –exe /usr/local/bin/bigloop –limit 40
Limit a process by PID to 55% CPU:
cpulimit –pid 2960 –limit 55
cpulimit should run at least with the same user running the controlled process. But it is much better if you run cpulimit as root, in order to have a higher priority and a more precise control.
Recent Comments