nice.1p (9600B)
- '\" et
- .TH NICE "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
- .\"
- .SH PROLOG
- This manual page is part of the POSIX Programmer's Manual.
- The Linux implementation of this interface may differ (consult
- the corresponding Linux manual page for details of Linux behavior),
- or the interface may not be implemented on Linux.
- .\"
- .SH NAME
- nice
- \(em invoke a utility with an altered nice value
- .SH SYNOPSIS
- .LP
- .nf
- nice \fB[\fR-n \fIincrement\fB] \fIutility \fB[\fIargument\fR...\fB]\fR
- .fi
- .SH DESCRIPTION
- The
- .IR nice
- utility shall invoke a utility, requesting that it be run with a
- different nice value (see the Base Definitions volume of POSIX.1\(hy2017,
- .IR "Section 3.244" ", " "Nice Value").
- With no options, the executed utility shall be run with a nice value
- that is some implementation-defined quantity greater 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
- .IR 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
- .IR utility
- or affect the exit status.
- .SH OPTIONS
- The
- .IR nice
- utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
- .IR "Section 12.2" ", " "Utility Syntax Guidelines".
- .P
- The following option is supported:
- .IP "\fB\-n\ \fIincrement\fR" 10
- A positive or negative decimal integer which shall have the same
- effect on the execution of the utility as if the utility had
- called the
- \fInice\fR()
- function with the numeric value of the
- .IR increment
- option-argument.
- .SH OPERANDS
- The following operands shall be supported:
- .IP "\fIutility\fR" 10
- The name of a utility that is to be invoked. If the
- .IR utility
- operand names any of the special built-in utilities in
- .IR "Section 2.14" ", " "Special Built-In Utilities",
- the results are undefined.
- .IP "\fIargument\fR" 10
- Any string to be supplied as an argument when invoking the utility
- named by the
- .IR utility
- operand.
- .SH STDIN
- Not used.
- .SH "INPUT FILES"
- None.
- .SH "ENVIRONMENT VARIABLES"
- The following environment variables shall affect the execution of
- .IR nice :
- .IP "\fILANG\fP" 10
- Provide a default value for the internationalization variables that are
- unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
- .IR "Section 8.2" ", " "Internationalization Variables"
- for the precedence of internationalization variables used to determine
- the values of locale categories.)
- .IP "\fILC_ALL\fP" 10
- If set to a non-empty string value, override the values of all the
- other internationalization variables.
- .IP "\fILC_CTYPE\fP" 10
- Determine the locale for the interpretation of sequences of bytes of
- text data as characters (for example, single-byte as opposed to
- multi-byte characters in arguments).
- .IP "\fILC_MESSAGES\fP" 10
- .br
- Determine the locale that should be used to affect the format and
- contents of diagnostic messages written to standard error.
- .IP "\fINLSPATH\fP" 10
- Determine the location of message catalogs for the processing of
- .IR LC_MESSAGES .
- .IP "\fIPATH\fP" 10
- Determine the search path used to locate the utility to be invoked.
- See the Base Definitions volume of POSIX.1\(hy2017,
- .IR "Chapter 8" ", " "Environment Variables".
- .SH "ASYNCHRONOUS EVENTS"
- Default.
- .SH STDOUT
- Not used.
- .SH STDERR
- The standard error shall be used only for diagnostic messages.
- .SH "OUTPUT FILES"
- None.
- .SH "EXTENDED DESCRIPTION"
- None.
- .SH "EXIT STATUS"
- If
- .IR utility
- is invoked, the exit status of
- .IR nice
- shall be the exit status of
- .IR utility ;
- otherwise, the
- .IR nice
- utility shall exit with one of the following values:
- .IP "1\(hy125" 8
- An error occurred in the
- .IR nice
- utility.
- .IP "\0\0126" 8
- The utility specified by
- .IR utility
- was found but could not be invoked.
- .IP "\0\0127" 8
- The utility specified by
- .IR utility
- could not be found.
- .SH "CONSEQUENCES OF ERRORS"
- Default.
- .LP
- .IR "The following sections are informative."
- .SH "APPLICATION USAGE"
- The only guaranteed portable uses of this utility are:
- .IP "\fInice\ utility\fR" 6
- .br
- Run
- .IR utility
- with the default higher or equal nice value.
- .IP "\fInice\ \fB\-n\ \fR<\fIpositive\ integer\fR>\fI\ utility\fR" 6
- .br
- Run
- .IR utility
- with a higher nice value.
- .P
- On some implementations they have no discernible effect on the invoked
- utility and on some others they are exactly equivalent.
- .P
- Historical systems have frequently supported the <\fIpositive
- integer\fP> 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.
- .P
- The nice value of a process can be displayed using the command:
- .sp
- .RS 4
- .nf
- ps -o nice
- .fi
- .P
- .RE
- .P
- The
- .IR command ,
- .IR env ,
- .IR nice ,
- .IR nohup ,
- .IR time ,
- and
- .IR 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
- .IR exec
- the utility fail with
- .BR [ENOENT] ,
- and uses 126 when any attempt to
- .IR exec
- the utility fails for any other reason.
- .SH EXAMPLES
- None.
- .SH RATIONALE
- The 4.3 BSD version of
- .IR nice
- does not check whether
- .IR increment
- is a valid decimal integer. The command
- .IR nice
- .BR \-x
- .IR utility ,
- for example, would be treated the same as the command
- .IR nice
- .BR \-\|\-1
- .IR utility .
- If the user does not have appropriate privileges, this results in a
- ``permission denied'' error.
- This is considered a bug.
- .P
- When a user without appropriate privileges gives a negative
- .IR increment ,
- System V treats it like the command
- .IR nice
- .BR \-0
- .IR utility ,
- while 4.3 BSD writes a ``permission denied'' message and does not run
- the utility. The standard specifies the System V behavior together
- with an optional BSD-style ``permission denied'' message.
- .P
- The C shell has a built-in version of
- .IR nice
- that has a different interface from the one described in this volume of POSIX.1\(hy2017.
- .P
- 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 POSIX.1\(hy2017.
- .P
- Historical implementations of
- .IR 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 raise the
- nice value of the executed utility by 10.
- .P
- Some historical documentation states that the
- .IR increment
- value must be within a fixed range. This is misleading; the valid
- .IR increment
- values on any invocation are determined by the current process
- nice value, which is not always the default.
- .P
- 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 POSIX.1\(hy2017 make the
- notion of a single underlying priority for all scheduling policies
- problematic. Some implementations may implement the
- .IR nice -related
- features to affect all processes on the system, others to affect just
- the general time-sharing activities implied by this volume of POSIX.1\(hy2017, and others may
- have no effect at all. Because of the use of
- ``implementation-defined'' in
- .IR nice
- and
- .IR renice ,
- a wide range of implementation strategies are possible.
- .P
- Earlier versions of this standard allowed a
- .BR \- \c
- .IR increment
- option. This form is no longer specified by POSIX.1\(hy2008 but may
- be present in some implementations.
- .SH "FUTURE DIRECTIONS"
- None.
- .SH "SEE ALSO"
- .IR "Chapter 2" ", " "Shell Command Language",
- .IR "\fIrenice\fR\^"
- .P
- The Base Definitions volume of POSIX.1\(hy2017,
- .IR "Section 3.244" ", " "Nice Value",
- .IR "Chapter 8" ", " "Environment Variables",
- .IR "Section 12.2" ", " "Utility Syntax Guidelines"
- .P
- The System Interfaces volume of POSIX.1\(hy2017,
- .IR "\fInice\fR\^(\|)"
- .\"
- .SH COPYRIGHT
- Portions of this text are reprinted and reproduced in electronic form
- from IEEE Std 1003.1-2017, Standard for Information Technology
- -- Portable Operating System Interface (POSIX), The Open Group Base
- Specifications Issue 7, 2018 Edition,
- Copyright (C) 2018 by the Institute of
- Electrical and Electronics Engineers, Inc and The Open Group.
- In the event of any discrepancy between this version and the original IEEE and
- The Open Group Standard, the original IEEE and The Open Group Standard
- is the referee document. The original Standard can be obtained online at
- http://www.opengroup.org/unix/online.html .
- .PP
- Any typographical or formatting errors that appear
- in this page are most likely
- to have been introduced during the conversion of the source files to
- man page format. To report such errors, see
- https://www.kernel.org/doc/man-pages/reporting_bugs.html .