Kernel decides how much processor time is required for a process based on
the nice value. Possible nice value range is: -20 to 20. A process that has a
nice value of -20 is very high priority. The process that has a nice value of 20
is very low priority.
$ ps axl
Use ps axl to display the nice value of all running process.
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
4 0 1 0 20 0 2100 724 - Ss ? 0:06 init [2]
5 0 2 0 15 -5 0 0 - S< ? 0:00 [kthreadd]
1 0 47 2 15 -5 0 0 - S< ? 0:00 [kacpid]
1 0 48 2 15 -5 0 0 - S< ? 0:00 [kacpi_notify]
1 0 125 2 15 -5 0 0 - S< ? 0:00 [kseriod]
1 0 166 2 20 0 0 0 - S ? 0:00 [pdflush]
[Note: 6th column 'NI' is the nice.]
To increase the priority, give a lower nice value as shown below. However, only root can increase the priority of a running process, else you’ll get error messages.
$ ps axl | grep test.sh
1 0 12345 2 15 10 0 0 - S< ? 0:00 test.sh
[Note: 6th column with value 10 is the nice value for the shell-script.]
Now decrease the nice value to increase the priority of the process. Use the PID of the process.
$ su - # renice -5 -p 12345
$ ps axl | grep test.sh
1 0 12345 2 15 -5 0 0 - S< ? 0:00 test.sh
[ Note: The 6th column now shows a lower nice value of -5 (increased priority)]