Linux Limit CPU Usage Per Process

I don’t want background process to eat all my CPU. I know how to find out CPU utilization but how do I limit the cpu usage of a process under Linux operating system? How do I force a process to limit itself to 25% only?

You can use cpulimit program that 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. Also, it is able to adapt itself to the overall system load, dynamically and quickly.

Install cpulimit

Type the following commands to install latest stable release:
# cd /tmp
# wget ''
# tar -zxvf cpulimit-1.1.tar.gz
# cd cpulimit-1.1
# make
# cp cpulimit /usr/local/sbin/
# rm -rf cpulimit*

A note about Debian / Ubuntu Linux users

Type the following command to install cpulimit:
$ sudo apt-get update
$ sudo apt-get install cpulimit

How do I use cpulimit?

To limit CPU usage of the process called firefox to 30%, enter:
# cpulimit -e firefox -l 30
To limit CPU usage of the process to 30% by using its PID, enter:
# cpulimit -p 1313 -l 30
To find out PID of the process use any of the following:
# ps aux | less
# ps aux | grep firefox
# pgrep -u vivek php-cgi
# pgrep lighttpd

You can also use absolute path name of the executable, enter:
# cpulimit -P /opt/firefox/firebox -l 30

  • -p : Process PID.
  • -e : Process name.
  • -l : percentage of CPU allowed from 0 to 100.
  • -P: absolute path name of the executable program file.

Root vs Normal User Account

From the project webpage:

cpulimit should run at least with the same user running the controlled process. But it is much better if you run cpulimit as root, in order to have a higher priority and a more precise control.

A Note About SMP (Multicore / MultiCpu) Systems

Again quoting from the project webpage:

If your machine has one processor you can limit the percentage from 0% to 100%, which means that if you set for example 50%, your process cannot use more than 500 ms of cpu time for each second. But if your machine has four processors, percentage may vary from 0% to 400%, so setting the limit to 200% means to use no more than half of the available power. In any case, the percentage is the same of what you see when you run top.

Related Throttling Utilities

  1. ionice utility – Avoid sudden outburst of backup shell script / program disk I/O.
  2. Limit disk I/O for rsync tool.
  3. Linux nice command: Run Process With Modified Scheduling Priority ( nicenesses )
  4. renice command: Change the Priority of a Already Running Process

Recommended Readings:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 37 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
37 comments… add one
  • sajmon May 23, 2009 @ 20:21

    does cpulimit runs firefox in your example, like nice?

    Or can it control cpu usage of already working programs?

  • 🐧 nixCraft May 23, 2009 @ 20:27

    Or can it control cpu usage of already working programs?

    Firefox is already running and icpulimit going to control its cpu usage.

  • Someone May 24, 2009 @ 0:02

    Would this work with uninterruptible processes (ones with a D state code)?

    I quite like it, and it could come in handy. Firefox at 5% is almost usable. :-p

  • absolut May 26, 2009 @ 18:59

    may you help me about this question? pls

    Create a C program which starts two processes.These processes work with common memory.The first process generates 20 random integer numbers.The second process reads them and writes the odd numbers in file F1, the even numbers in file F2

  • nima chavoshi Jun 25, 2009 @ 11:19

    thanks a lot, it’s so nice :)

  • Milad Jul 8, 2009 @ 19:55

    How i can use cpulimit for my user on the server . for example my one user can use only 5% of the cpu and other user can use the 10 % of my server cpu?

  • Nazeem S Jul 13, 2009 @ 6:59


  • Felipe Aug 22, 2009 @ 4:49

    Thanks, but i get an error:

    Segmentation fault (core dumped)

    An core dump file is created when i run cpulimit for limit apache (httpd).

    My server is an Core2Quad 64 Bits…maybe cause i’m using 64 Bits?


  • Slawek Oct 7, 2009 @ 10:56

    I would like to limit CPU usage by command :
    gzip -9 somename.gz
    How to use cpulimit with it.
    # cpulimit -l 30 -e gzip -1 file.gz
    cpulimit: invalid option — ‘1’
    Any ideas ?
    regards to you all

    • ham5ter Jun 17, 2016 @ 9:37

      cpulimit -l 30 -e gzip — -1 file.gz

  • Slawek Oct 7, 2009 @ 11:09

    Sorry original command was:
    gzip -1 file.gz
    # cpulimit -l 30 -e gzip -1 file.gz
    cpulimit: invalid option — ‘1’

  • J. Ruiz Oct 21, 2009 @ 8:16


    At current version of cpulimit (1.1) does *not* support programs execution directly from cpulimit.
    You have two ways to do it:
    – First, limit the cpu usage of gzip command and then, run gzip.
    – Run gzip and then limit its cpu usage with cpulimit.

    Only development version support programs execution directly.

  • Josh Oct 22, 2009 @ 16:14

    I am trying to limit the gzip process, however, it isn’t currently running. Is there a way to make it so whenever a process runs it is limited?

  • J. Ruiz Oct 22, 2009 @ 22:23


    Run this “cpulimit -l -e gzip”. Leave it running, for example, in a detached screen or in background adding the character “&” at the end.

  • karunakar Nov 23, 2009 @ 16:53


    I tried to install this and use. but i am getting “Segmentation fault (core dumped)” error.
    How do I solve this?

    Thanks & regards,
    karunakar gowni

    • Rob Jun 2, 2011 @ 18:00

      I was getting seg faults as well but using the latest svn version fixed this for me:

      svn checkout cpulimit
      cp cpulimit /usr/local/sbin

      yum install subversion if necessary.

    • erm3nda Jan 21, 2015 @ 4:09

      I got same error, but was about a unfinished compilation error.
      Binary was malformed but writed out, and segmentation was the output.

      I compile it from another PC and the binary is now working.

  • O2Link Dec 8, 2009 @ 17:42

    Thank you!

  • Pugazendhi Asaimuthu Dec 23, 2009 @ 20:31

    tar cpulimit-1.1.tar.gz
    returned, on CentOS, “/bin/tar: Old option `g’ requires an argument.”
    The following worked.
    tar -xvzf cpulimit-1.1.tar.gz

    • sri Apr 23, 2014 @ 10:13

      Hello Pugazendhi,

      Can you please help me figure out how to find if the CPU is capped or not in a linux system?


  • 🐧 nixCraft Dec 24, 2009 @ 5:32

    @ Pugazendhi,

    Thanks for the heads up, it was a typo on my part!

  • NixNoob Mar 9, 2010 @ 17:32

    Hi, I am fairly new to Linux. I followed your instructions and was able to install cpulimit – Thanks! My question is: I have a scheduled backup job that starts/stops a “java” process which hammers the CPU. Is there a way to auto-limit the the CPU usage of the java process when it starts?

  • Alex Jul 2, 2010 @ 2:43

    Why script does not work in CentOS 5.5 (kernel 2.6.18)?
    And if you run:
    cpulimit-P / opt / firefox / firebox-l 30
    then cpulimit works fine.

  • ultramen7 Oct 1, 2010 @ 4:37

    hi guys,..
    can i use cpulimit to user or group ?.. means, user A can use 10 % cpu and user B can use 20 % cpu,..


  • ege Oct 13, 2010 @ 2:15

    Thank you very much. Saved my butt on a broken Acer Aspire 5715Z that has an abysmall overheating problem constantly triggered by Firefox. Amazingly, I haven’t even noticed any performance decrease at 30%. CPU temperature dropped to 68 degrees celcius, from unoperatable 98 degrees. Beautiful.

  • GVV Sep 13, 2011 @ 15:07

    Hi !!
    I dont use to post comments, but this cpulimit really made my day… It works great. !!
    Thank you guys

  • Rohit Dec 31, 2011 @ 8:26

    root@uss [/home]# cpulimit -P /home/vivek -l 20
    Warning: no target process found. Waiting for it…

    And it’s taking time.. How do I block vivek? :(

  • Majes Apr 14, 2012 @ 13:05

    Excellent job, does what it is meant to do flawlessly.

    Highly recommend this for any resource hogs ya might need to run.


  • Angelo Jun 24, 2012 @ 12:45

    I’m the author of cpulimit. It now supports FreeBSD and will support Mac OS soon.
    Latest code is available in the new github project:

    Stay tuned!

  • Deryck Sep 10, 2012 @ 3:31

    Hi, I have a VPS runing php-cgi process per user. Can I limit all the php-cgi process (currents and news) using cpulimit? How can I do that?

    Thanks in advance.

  • Mahesh Sep 25, 2012 @ 6:56

    Inspite of installing subversion when changing the cpu usage value to pid showing segmentation failed

  • SAM Apr 12, 2013 @ 9:29

    I RUN command TOP and always first 2-4 process are php-cgi
    their pid always change. hence i don’t think it gonna work much.
    i did applied it at kloxo and 1 tcpserver and haven’t seen much of the difference.

    do i need to regularly apply this command or just once and done?

  • Jake Jul 24, 2013 @ 10:06

    How to unlimit all limited processes without shutting down the linux server?

  • Jake Jan 26, 2014 @ 13:39

    Hey there,

    I loved using cpulimit on my linux box. However I then moved on to a mac and although the author of the script has given support for the mac the “-e” along with process name does not work.

    This requires me to always have to find out the process id using “top” and then add it to my .command shortcut. The details of my issue are posted on the github where the author posted his script.

    I can understand that it would be a while before I get a reply, I saw that this issue had been posted earlier.

    I know your post is on how to use cpulimit for linux. I was wondering if your an expert at scripts if it would be possible to write a small script to find out the pid of a process in mac and then use that pid in the command line to execute cpulimit.

    I tried searching and could not find how I could do this.

    Pl. help, I just use cpulimit for HandBrake and nothing else.


    • 🐧 Nix Craft Jan 26, 2014 @ 16:27

      Use pgrep command to get PID:

      pgrem "firefox"
      pgrep "HandBrake"
  • eoeoe May 26, 2014 @ 21:40

    how to remove limit for all process limited with cpulimit on centos ?
    sorry for my bag english :(

  • kthx Feb 22, 2015 @ 15:44

    doesn’t work… and no I have no “upstart” on my box… I set cpulimit for dpkg because LA is over 20… I seen it high as 26, on a single core server…

    I ran cpulimit, it sits there looping doing nothing but blocking my tty, and I load top in other tty to see it still above 10…

    It should be 1.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum