Thursday, August 5, 2010

How to limit CPU ususage for a process?

Here are the steps those I followed :

Install cpulimit binary:-

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

Note : You can search the latest tar file.

===
if gcc is not on the server, please run yum install gcc*. I got error here.
===

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

====
PS:

[root@cy cpulimit-1.1]# cpulimit --help
Usage: cpulimit TARGET [OPTIONS...]
TARGET must be exactly one of these:
-p, --pid=N pid of the process
-e, --exe=FILE name of the executable program file
-P, --path=PATH absolute path name of the executable program file
OPTIONS
-l, --limit=N percentage of cpu allowed from 0 to 100 (mandatory)
-v, --verbose show control statistics
-z, --lazy exit if there is no suitable target process, or if it dies
-h, --help display this help and exit
[root@cy cpulimit-1.1]#
=====

Try :)

No comments:

Post a Comment