CPULimit - это простая программа для ограничения использования ЦП определенного приложения в Linux. По умолчанию он находится в репозиториях Ubuntu. Мы можем установить его, выполнив следующую команду в Ubuntu
sudo apt-get install cpulimit
Выход
mkyong@mkyong:~$ sudo apt-get install cpulimit[sudo]password for mkyong: Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-2.6.28-11 linux-headers-2.6.28-11-generic Use 'apt-get autoremove' to remove them. The following NEW packages will be installed: cpulimit 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 9730B of archives. After this operation, 65.5kB of additional disk space will be used. Get:1 http://my.archive.ubuntu.com jaunty/universe cpulimit 1.1-11[9730B]Fetched 9730B in 1s (8940B/s) Selecting previously deselected package cpulimit. (Reading database ... 131942 files and directories currently installed.) Unpacking cpulimit (from .../cpulimit__1.1-11__i386.deb) ... Processing triggers for man-db ... Setting up cpulimit (1.1-11) ... mkyong@mkyong:~$
Мы можем ограничить использование ЦП приложения либо по имени исполняемого файла, либо по идентификатору процесса (pid). Например, у нас есть задание cron, написанное на python (name = mycronjob.py, pid = 1234)
Ограничьте процесс "mycronjob.py" по имени исполняемого файла до 50% загрузки процессора
cpulimit -e mycronjob.py -l 50
Ограничить процесс с помощью PID (1234) до 50% CPU:
cpulimit -p 1234 -l 50
Это довольно полезная программа, чтобы предотвратить использование приложением всех наших процессоров :)
ссылка://тег/процессор/[процессор]ссылка://тег/unix/[unix]