Currently, this program is only available on Debian / Ubuntu you can install using the following command:
sudo apt install cputool
Limit process with CPULimit
Let us first learn about how cpulimit works, let's first try running a command dd Hard Drive .
dd if=/dev/zero of=/dev/null &
You can track your progress in action with the command: top
Here I see that this process always runs with 100% cpu (1 core), now I try limited to CPUtool.
You use the -cpu-limit or -c options to limit the process's cpu usage, -p to specify which processes need to be restricted.
For example, I limit the above process to a PID of 8275 with 50% (1 core).
cputool --cpu-limit 50 -p 8275
After running, you can check the active progress with the command top
Suppose I want to reset 20%:
cputool --cpu-limit 20 -p 8275
Note: When running this program, after entering the command you do not operate on the keyboard to keep the program running, to exit you can press ctrl + X.
You can also find and group programs by specifying a unique PID. For example, if you want to find processes running by apache you can use:
pidof apache2
Result.
# pidof apache2
9592 3643 3642 3641 3640 3638 3637 1780
You can use the following command to limit all apache processes
cputool --cpu-limit 20 -P 1780
You note, you use the -P option (capital letter P), unlike the first example, which is lowercase p.
You can see more information with:
man cputool
Good luck.
0 Comments