To install cpulimit on Ubuntu, do as below
apt-get install cpulimit
Install on Centos 7
install epel-release install cpulimit
We limit CPU usage by using the --limit
or -l
option to set a usage percentage for a process. Before limiting the CPU usage, you need to find the process or the command that is using all your CPU time
There are three ways to use cpulimit by acting
--executable
or -e
option
cpulimit -e program -l %cpu
-P
option
cpulimit -P path -l %cpu
--pid
or -p
option
cpulimit -p process_pid -l %cpu
So, we will first check the process/program which consumes the CPU time
# top
You can limit the CPU usage with the process id as below
# cpulimit -p 31177 -l 60 Process 31177 found
And you can see the result below
You can run cpulimit in the background by using the --background
or -b
option