Archives For November 30, 1999

Want to limit the cpu usage of an app or process? It’s easy to do the trick in Ubuntu Linux via the LimitCPU tool.

LimitCPU is a simple command line tool that monitors a process and makes sure its CPU usage stays at or below a given percentage, by sending SIGSTOP and SIGCONT POSIX signals to process. All the children processes and threads of the specified process will share the same percentage of CPU.

LimitCPU is the direct child of the old CPUlimit. It’s available in the system repositories of all current Ubuntu repositories, though the package name is cpulimit.

Install LimitCPU in Ubuntu:

Press Ctrl+Alt+T on keyboard to open terminal. When it opens, run command to install the tool:

sudo apt install cpulimit

How to use Limit CPU in Ubuntu:

It’s quite easy to use the tool, because it has a good documentation. Just run man cpulimit in terminal, it will tell you how to use it. For lazy men, here are some examples.

1. Specify app or process to limit via:

  • -p follow with process id
  • -e follow with executable file name.
  • -P follow with absolute path to executable file.

For example, make sure process ‘1123’ to use less than 50% CPU (-l follow with number specify allowed CPU).

cpulimit -p 1123 -l 50

Many apps now use multiple processes, so you may specify which to limit via path to executable:

cpulimit -P /usr/bin/firefox -l 50

2. The tool can also used to launch an app and limit its CPU usage. For example, launch Firefox and allow up to 50% CPU amount:

cpulimit -l 50 firefox

3. There are some other command line flags, including:

  • -c specify the number of CPU cores available for the process.
  • -b / -f run cpulimit in background / foreground.
  • -q run in quite mode.
  • -k, kill the process when reach CPU limit.
  • -s, send alternative signal to watched process when kill it.

For example, launch Firefox and kill it when reach 30% CPU usage:

cpulimit -l 30 -k firefox

Limit process ‘1123’ to 25% CPU and allows 2 cores:

cpulimit -c 2 -p 1123 -l 25

Kill Firefox and send SIGTERM signal when it uses 20% CPU:

cpulimit -l 20 -e firefox -s SIGTERM

As mentioned, run man cpulimit in terminal for more information.

CPUPower-GUI is a simple graphical utility allows to change the frequency limits of your cpu and its governor.

With the tool, you can easily change the frequency settings on per CPU core basis. Just choose a profile you want to configure, then highlight each cpu core, and set its minimize and maximize frequency using the slider-bars. By default, it has only built-in “Balanced” and “Performance” profiles, but you can create your own in “Profiles” tab and set its frequency for each core as you prefer.

You can also change the cpu governor profiles, Performance and Balanced. And the profiles can be selected easily from the system tray indicator menu.

After setup your profiles, you can configure which to use on startup along with a few other options in the second Preference tab.

How to Install cpupower-gui in Ubuntu:

The software is available in Ubuntu universe repositories since Ubuntu 20.04. The package however is always old.

UPDATE: the 1.0.0 release do NOT work in Ubuntu 22.04 and higher !!

The software developer now offers the official .deb packages for downloading in the Github releases page:

Download and install the .deb package. Then press Ctrl+Alt+T on keyboard to open terminal and install it via:

sudo apt install ./Downloads/cpupower-gui*all.deb

For Linux Mint, grab the last 3 .deb packages instead and install them using Gdeb package installer.

For the source tarball and more about the utility, go to github project page.