HP-UX Reference (11i v2 07/12) - 1 User Commands N-Z (vol 2)
n
nice(1) nice(1)
NAME
nice - run a command at nondefault priority
SYNOPSIS
nice [-priority_change] command [command_args]
nice [-n priority_change] command [command_args]
DESCRIPTION
The
nice command executes command at a nondefault CPU scheduling priority. (The name is derived
from being "nice" to other system users by running large programs at lower priority.)
Arguments
The command-line arguments are as follows:
-n priority_change
priority_change The difference between the system nice value (relative priority) of the current (or
parent) process and the actual system nice value at which command is to run.
An unsigned value increases the system nice value for command, causing it to run at
lower priority.
A negative value requires superuser privileges, and assigns a lower system nice value
(higher priority) to command. If the current process is not privileged, the value is
silently treated as if it were 0.
If the value of priority_change would result in a system nice value outside the range
0 through 39, the corresponding limit value of 0 or 39 is used instead.
Note that a positive priority_change (lower priority) has a single
- option character
before the numeric value; a negative (higher priority) priority_change has two: the
option character followed by the minus sign (
--). If -priority_change is not
specified, it defaults to
10.
command A program, HP-UX command, user shell script, etc. to be executed at the nondefault
priority. command can be run as a foreground or background process.
If command is run as a background process, any nice priority_change made by the
shell (
ksh executes all background processes via nice -4) is in addition to that
specified in the nice command line.
command_args Any arguments recognized by command.
Process Priorities
All processes have an associated system nice value which is used to compute the instantaneous-priority of
the process when it is scheduled to run. Normally, all processes inherit the system nice value of their
parent process when they are spawned. The shell (sh, csh, ksh, etc.) can create a child process with a
different priority from the current shell process by spawning the child process via the
nice command. If
the priority_change value is unsigned (positive), the child process is nicer (lower in priority) relative to the
parent. If the priority_change value is negative, the child process runs at a higher priority with a greater
share of available system resources. To spawn a higher priority child process, the parent process must be
owned by a user who has the appropriate privileges.
At boot-up, the system starts the
init process at a system nice value of 20 (system default). On most sys-
tems, all processes (down to the login shells) inherit this priority. Starting from their individual login shell
processes, users can alter the system nice value of descendent processes to as much as 39, or, with
appropriate privileges, as little as 0. A system nice value of 0 establishes an extremely high priority,
whereas a value of 39 indicates a very low priority.
Ordinary users can only increase the system nice value of any child process relative to the current process;
i.e., priority_change must be a positive (unsigned) value, resulting in a lower priority. To start a child pro-
cess at a lower system nice value (higher priority) than the current process, the user must have the
appropriate privileges, regardless of the relative nice-priority value desired.
For example, using the command
nice ksh
HP-UX 11i Version 2: December 2007 Update − 1 − Hewlett-Packard Company 45