The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

nice - invoke a utility with an altered system scheduling priority

 SYNOPSIS



nice [-n increment] utility [argument...]

nice [-increment] utility [argument...]

 DESCRIPTION

The nice utility invokes a utility, requesting that it be run with a different system scheduling priority (see the definition of system scheduling priority in the XBD specification, Glossary  ). With no options and only if the user has appropriate privileges, the executed utility is run with a system scheduling priority that is some implementation-dependent quantity less than or equal to the system scheduling priority of the current process. If the user lacks appropriate privileges to affect the system scheduling priority in the requested manner, the nice utility will not affect the system scheduling priority; in this case, a warning message may be written to standard error, but this will not prevent the invocation of utility or affect the exit status.

 OPTIONS

The nice utility supports the XBD specification, Utility Syntax Guidelines  except that the obsolescent version allows a multi-digit decimal integer as an option name.

The following option is supported:

-n increment
-increment
Specify how the system scheduling priority of the executed utility will be adjusted. The increment option-argument is a positive or negative decimal integer that will be used to modify the system scheduling priority of the executed utility in an implementation-dependent manner. Positive increment values cause a lower or unchanged system scheduling priority. Negative increment values may require appropriate privileges and will cause a higher or unchanged system scheduling priority. The system scheduling priority is bounded in an implementation-dependent manner. If the requested increment would raise or lower the system scheduling priority of the executed utility beyond implementation-dependent limits, then the limit whose value was exceeded is used.

 OPERANDS

The following operands are supported:
utility
The name of a utility that is to be invoked. If the utility operand names any of the special built-in utilities in Special Built-in Utilities , the results are undefined.
argument
Any string to be supplied as an argument when invoking the utility named by the utility operand.

 STDIN

Not used.

 INPUT FILES

None.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of nice:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .
PATH
Determine the search path used to locate the utility to be invoked. See the XBD specification, Environment Variables  .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

Not used.

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

None.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

If the utility utility is invoked, the exit status of nice will be the exit status of utility; otherwise, the nice utility will exit with one of the following values:
1'
An error occurred in the nice utility.
126
The utility specified by utility was found but could not be invoked.
127
The utility specified by utility could not be found.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

Note that, in the obsolescent version, -5 is a positive increment, while --5 is a negative increment.

The only guaranteed portable uses of this utility are:

nice utility
Run utility with the default lower system scheduling priority.
nice -n <positive integer> utility
Run utility with a lower system scheduling priority.

On some systems they will have no discernible effect on the invoked utility and on some others they will be exactly equivalent.

Historical systems have frequently supported the <positive integer> up to 20. Since there is no error penalty associated with guessing a number that is too high, users without access to the system conformance document (to see what limits are actually in place) could use the historical 1 to 20 range or attempt to use very large numbers if the job should be truly low priority.

The system scheduling priority value of a process can be displayed using the command:


ps -o nice

The command, env, nice, nohup, time and xargs utilities have been specified to use exit code 127 if an error occurs so that applications can distinguish "failure to find a utility" from "invoked utility exited with an error indication". The value 127 was chosen because it is not commonly used for other meanings; most utilities use small values for "normal error conditions" and the values above 128 can be confused with termination due to receipt of a signal. The value 126 was chosen in a similar manner to indicate that the utility could be found, but not invoked. Some scripts produce meaningful error messages differentiating the 126 and 127 cases. The distinction between exit codes 126 and 127 is based on KornShell practice that uses 127 when all attempts to exec the utility fail with [ENOENT], and uses 126 when any attempt to exec the utility fails for any other reason.

 EXAMPLES

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

renice.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]