How to Install and Use CPULimit to monitor CPU in Linux

Estimated reading: 1 minute 1471 views

Install cpulimit

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

  1. on the executable program with the --executable or -e option
    cpulimit -e program -l %cpu
  2. on the absolute path name of the file with the –path or -P option
    cpulimit -P path -l %cpu
  3.  on the PID of the process with the --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

Click here to buy our VPS!


Leave a Comment