nice - invoke a utility with an altered nice value
nice [-n increment] utility [argument...]
The nice utility shall invoke a utility, requesting that it be run with a different nice value (see the Base Definitions volume of IEEE Std 1003.1-2001, Section 3.239, Nice Value). With no options and only if the user has appropriate privileges, the executed utility shall be run with a nice value that is some implementation-defined quantity less than or equal to the nice value of the current process. If the user lacks appropriate privileges to affect the nice value in the requested manner, the nice utility shall not affect the nice value; in this case, a warning message may be written to standard error, but this shall not prevent the invocation of utility or affect the exit status.
The nice utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
The following option is supported:
The following operands shall be supported:
The following environment variables shall affect the execution of nice:
The standard error shall be used only for diagnostic messages.
If utility is invoked, the exit status of nice shall be the exit status of utility; otherwise, the nice utility shall exit with one of the following values:
The following sections are informative.
The only guaranteed portable uses of this utility are:
Run utility with the default lower nice value.
Run utility with a lower nice value.
On some implementations they have no discernible effect on the invoked utility and on some others they are 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 nice 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.
Due to the text about the limits of the nice value being implementation-defined, nice is not actually required to change the nice value of the executed command; the limits could be zero differences from the system default, although the implementor is required to document this fact in the conformance document.
The 4.3 BSD version of nice does not check whether increment is a valid decimal integer. The command nice -x utility, for example, would be treated the same as the command nice --1 utility. If the user does not have appropriate privileges, this results in a "permission denied" error. This is considered a bug.
When a user without appropriate privileges gives a negative increment, System V treats it like the command nice -0 utility, while 4.3 BSD writes a "permission denied" message and does not run the utility. Neither was considered clearly superior, so the behavior was left unspecified.
The C shell has a built-in version of nice that has a different interface from the one described in this volume of IEEE Std 1003.1-2001.
The term "utility" is used, rather than "command", to highlight the fact that shell compound commands, pipelines, and so on, cannot be used. Special built-ins also cannot be used. However, "utility" includes user application programs and shell scripts, not just utilities defined in this volume of IEEE Std 1003.1-2001.
Historical implementations of nice provide a nice value range of 40 or 41 discrete steps, with the default nice value being the midpoint of that range. By default, they lower the nice value of the executed utility by 10.
Some historical documentation states that the increment value must be within a fixed range. This is misleading; the valid increment values on any invocation are determined by the current process nice value, which is not always the default.
The definition of nice value is not intended to suggest that all processes in a system have priorities that are comparable. Scheduling policy extensions such as the realtime priorities in the System Interfaces volume of IEEE Std 1003.1-2001 make the notion of a single underlying priority for all scheduling policies problematic. Some implementations may implement the nice-related features to affect all processes on the system, others to affect just the general time-sharing activities implied by this volume of IEEE Std 1003.1-2001, and others may have no effect at all. Because of the use of "implementation-defined" in nice and renice, a wide range of implementation strategies are possible.
Shell Command Language , renice , the System Interfaces volume of IEEE Std 1003.1-2001, nice()
Закладки на сайте
Проследить за страницей
Created 1996-2023 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру