United States-English |
|
|
HP-UX Reference > Nnice(1)HP-UX 11i Version 3: February 2007 |
|
NAMEnice — run a command at nondefault priority SYNOPSISnice [-priority_change] command [command_args] nice [-n priority_change] command [command_args] DESCRIPTIONThe 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.) ArgumentsThe command-line arguments are as follows:
Process PrioritiesAll 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 systems, 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 process 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 from a login shell whose current nice value is 20 spawns a subshell with a system nice value of 30. Attempting to use nice --2 ksh from the new shell to spawn another subshell whose system nice value would be 28, is rejected (unless the user has appropriate privileges), even though the resulting system nice value would be less than the priority of the original login shell process. The system nice value for current processes is listed under the NI column produced by the ps -l command (see ps(1)). Background ProcessesForeground processes are run at same system nice value as the parent shell. Background processes spawned by ksh run at the equivalent of a nice -4 by default. If a background process is started via nice from ksh, any priority_change specified in the nice command is added to default nice -4. Thus the command nice 12 command & runs at a system nice value of 36 if executed from ksh. EXTERNAL INFLUENCESEnvironment VariablesLC_MESSAGES determines the language in which messages are displayed. If LC_MESSAGES is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG. If any internationalization variable contains an invalid setting, nice behaves as if all internationalization variables are set to "C". See environ(5). EXAMPLESThe following examples assume the current process is running with a system nice value of 20 and nice is executed from the Korn shell (see ksh(1)). Run a program named prog in the current directory at the default priority_change of 10 (system nice value of 30): nice ./prog prog_args Run the same program in the background using a system nice value of 36 (priority_change=12 plus 4 for the Korn shell): nice -12 ./prog prog_args & As a user with appropriate privileges, run prog as a foreground process with a system nice value of 6: nice --14 ./prog prog_args WARNINGSThe C shell, csh, has a built-in nice command with different syntax. See csh(1) for details. |
Printable version | ||
|