CPULIMIT : limit a process’s consumption !

In GNU/Linux on March 1, 2010 at 4:49 pm

I am really happy when I saw this!

B’se I ‘ve been thinking how to limit my processes consumption of CPU usage. Finally I got it there…. Just by installing cpulimit we can control it!

I was wondering when I use my virtual box to run Turbo C++ on the Windows XP , it consumes 101-104% of my CPU. I was awestruck when I first saw that, then I wondered how to control that. Finally I got a solution from here. Thanks to the author!
It is like this:

$ sudo apt-get install cpulimit

This installs ‘cpulimit‘. Now see the output of  the –help option:

$ sudo apt-get --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
 -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

Now , Just see some of its usage examples:

$ sudo cpulimit --pid 4423 --limit 50

This will limit the process with process id (pid) 4423 to only use 50% . Similarly  the others also
-P option uses absolute path but -e or –exe uses just the name  of the process.

$ sudo cpulimit --exe firefox --limit 30
$ sudo cpulimit -P /usr/bin/example --limit 20

Its quite easy, right !
NOTE: Better to run the commands with Alt+F2 ! as it runs till the end of the process!
Ok njoy the day 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: