CPU Limit Ubuntu Server 11.04 Command Line


I’ve was encrypting some files the other day with GPG and found that while the encryption was taking place my computer ground to a halt because GPG was taking up all of my CPU. Normally I wouldn’t mind this as I would just setup a few jobs and go make a cup of tea. Then I though what would happen if I run my encryption jobs on a webserver, well it grinds to a halt. So how do we run encryption jobs on our servers without affecting users,well first off we could just by a multi core processor and put it in your, server that’s the fastest way of fixing the problems. However if you’re like me, lazy, then you can use a tool called CPU limit, to limit the amount of a single CPU a process can run, to get started just type:



Sudo apt-get install cpulimit

Once cpulimit is installed all you need to do is run the program you want to limit then type the following substituting [program] to the program you want to run, i.e gpg:

sudo cpulimit -e "[program]" -l 30




And that’s about it, cpulimit will throttle your chosen program to 30% CPU usage.

, , , ,

  1. No comments yet.

You must be logged in to post a comment.

Comments are closed.