nice executes command with the ``nice'' value number. The nice value is one of the factors used by the kernel to determine a process's scheduling priority. Scheduling priorities range from 0 to 127. The higher the value, the lower the command's scheduling priority, and the lower the value, the higher the command's scheduling priority. In addition to the nice value, the kernel also recent CPU usage by the process, the time the process has been waiting to run, and other factors to arrive at scheduling priority.
If the number argument is present, the nice value is incremented or decremented by that amount, between the limits -20 and 19. If there is no number argument, the default nice value is 10 for the Bourne shell, and 4 for the C-shell.
The super-user may run commands with priority higher than normal by using negative nice values, such as -10.
The following examples illustrate the use of nice values for users (not the super-user) using /usr/bin/nice. The examples use the -l option to ps.1 because it shows both the nice value and the kernel scheduling priority. Notice the NI and PRI columns. In the first example, the user doesn't use nice, so the niceness is zero, the default value, which is reflected by 0 in the NI column. The corresponding process scheduling priority is shown in the PRI column as 28 (this may vary because of the other factors the kernel's scheduler uses).
In the second example, the user uses a nice value of 10, and the corresponding priority is 53, a higher numerical value but a lower priority. Notice that this is the same as:
example% nice ps -l
In the third example, the user asks that the nice value be incremented by 20, but it's shown as 19 under NI, because that's the upper limit of niceness.
A fourth example shows the error message when an ordinary user tries to decrement the nice value.
example% ps -l F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND ... 19442 16623 9725 12 28 0 120 336 R p2 0:00 ps -l ... example% nice -10 ps -l F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND ... 19442 16608 16606 32 53 10 120 328 R N p2 0:00 ps -l ... example% nice -20 ps -l F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND ... 19442 16609 16606 37 72 19 120 328 R N p2 0:00 ps -l ...
example% nice --20 ps -l nice: setpriority: Permission denied example%
increments the nice value by number. It uses a single a minus sign, -, to decrement nice values for super-user.
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97