Limit CPU for a process

CPU Limit is a tool that allows you Limit the amount of CPU Time your Linux gives to a certain process. It is also very easy to use.

Last week I installed cpulimit to help me throttle nginx php-cgi process. When running a web server with php this can be a CPU hog so I decided to try and limit the CPU time php-cgi gets.

First install it

sudo apt-get install cpulimit

To Use run this

sudo cpulimit --path=/usr/bin/someBinary -l 70 -z -b

That will limit that binary to 70% CPU time and by running cpulimit in the background.

Continue reading “Limit CPU for a process”

How to set PATH variables Linux, Bash

Hey there, this is a classic question in Linux systems.

It shows whenever you wanna run certain command and you get


admin@yourserver:~$ whatever
bash: whatever: command not found

You need to add ‘whatever’ (or the program you want) path into your current path

To see your current path do this


admin@yourserver:~$ echo $PATH
/usr/local/bin:/bin:/usr/local/games:/usr/games

You can see my current path, lets say I want to add /usr/bin I will do this

PATH=$PATH:/usr/bin

note: You don’t need export if the variable is already exported: any change of the value of the variable is reflected in the environment. (This wasn’t true in older shells, but you’re highly unlikely to encounter such old shells these days.)
Check this post for more info

Now you can check again


admin@yourserver:~$ echo $PATH
/usr/local/bin:/bin:/usr/local/games:/usr/games:/usr/bin

Check how /usr/bin was added to the end.

And that’s it very easy and useful, next time just call command by name instead of full path 😉