Console logo</img>

How to assign and reassign priority to Linux commands or processes, to optimize your CPU ussage

You may have seen this problem with your Linux sometimes, you are working with your normal applications, like browsing the web, using Open Office or any other thing, and then Linux start a cron process or you start a make command, and all the other applications slow down.

Well you can solve that by entering different priorities to different applications, this is done with the nice and renice commands. Lets say you need to compile a program, and do not want it to eat all the processor power and attention, so you can still perform other actions.


nice make all

Here the nice command will increase the niceness by 10 (the default increment if nothing else is indicated).

And how nice work?, well it adjust priority from -20 (most favorable scheduling) to +19 (least favorable scheduling).

Only root can assign a lower priority (negative number) while the rest of users can only decrease the priority of a process.

You an also reassign the priority while a command is running, to do this you need to use renice command, or better using htop

See the picture below:

htop Linux command screen shot</img>

You just need to highlight the command you want to act on, (using arrow keys) and then press F7 to increase priority, or F8 to decrease priority. Note that you need to own the process if you are not root, and also if you are not root, you can only decrease priority.

nice man page

renice man page