Limit cpu usage using cpulimit

OK I know, that you know how to check the cpu utilization of a process using top, htop, mpstat and sar command. You might have learned this in your linux training.

We can view the cpu being consumed by a process. But how to control it?

Here comes a very simple fun tool – cpulimit

Feel free to download it fromĀ http://cpulimit.sourceforge.net/

Those using ubuntu can download it by this simple command.

sudo apt-get install cpulimit

Now the best thing about cpulimit is that it attempts to limit the cpu usage of a process. Limits are expressed in percentage and not in cpu time. cpulimit does not act on the nice value or other scheduling priority stuff, but on the real cpu usage.

Example #1 – To limit the cpu usage of a process evolution under 20%.

sudo cpulimit -e evolution -l 20

Example #2. You can also use the pid of the process for the same job.

sudo cpulimit -p 8888 -l 20

Here is the screenshot from my machine.. enjoy !!

cpulimit to control cpu usage

cpulimit to control cpu usage

Advertisements