Thursday, June 28, 2012
1:25 PM

Using nice to assign priority to process

Linux maintains the priority of normal processes using a number called as the nice number.
The number ranges from -20 to +19 and smaller the number higher is the priority.
The name nice signifies that higher the nice value of a number the nicer it is to other processes.
To view the nice values of a process we can use the command "ps" as below.



In the above output the first column is the command or the process name, the second is the process id and the third is the nice value of the process.

The default nice value of a process is 0, thus most of the processes have a nice value 0.
We can launch a process with a nice value we want by using the command nice.
For example if we want to launch the gedit editor with a nice value of -1 we can do it using



Now if we do the process listing as above we should see the gedit listed with a nice value of -1.



Thus if we want to set a process to have a high priority we can start the same with a low nice value,lowest possible being -20.


0 comments:

Post a Comment