If you want it to work every time you start a process, write a small script to start your process and include the cpulimit command as follows: #!/bin/bash You can set the limiter to run in the background with the –background or -b option. Usually, 40% – 50% is a good limit to set. Granted, this was not a great example, you would normally only want to limit a process that was running away at over 90% CPU usage. This will result in the process you have restricted running at approximately 10% CPU usage at the most ( in reality it might even reach 11% or 12% ). You can also use the PID (Process ID) as follows: cpulimit -p 3511 -l 10 Process 3511 detected (the PID of the initial chrome command) Now you can use the following command: cpulimit -e chrome -l 10 After you have identified the program in top or htop, you will be able to find the NAME as follows (red arrow on the right): Use top, or even better, install htop and use this to find the offending program.Ĭpulimit can be invoked in one of three ways, but we will focus on using the NAME of the process first. Please note that total CPU percentage available is usually (100 x number of CPU Cores). Limiting actual usage is done by using the –limit or -l switch option to set the CPU percentage for a process. It still works, but why type more than needed? The command will also work on Ubuntu 18 and 20.Įxecute the following command: apt install cpulimit Install cpulimit on Centos 7Ĭpulimit is part of the EPEL repository yum install epel-release yum install cpulimit Ubuntu 16 has done away with the apt-get and apt-cache, etc syntax. Make sure you have root for the commands below, or insert the sudo prefix before each command. It is not included in the operating system and has to be installed. Use cpulimit to limit CPU usage.Ĭpulimit is a command line tool written in C.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |