Runs a command at a lower or higher priority.
The nice command lets you run a command at a priority lower than the command's normal priority. The Command parameter is the name of any executable file on the system. If you do not specify an Increment value the nice command defaults to an increment of 10. You must have root user authority to run a command at a higher priority. The priority of a process is often called its nice value.
The nice value can range from -20 to 19, with 19 being the lowest priority. For example, if a command normally runs at a priority of 10, specifying an increment of 5 runs the command at a lower priority, 15, and the command runs slower. The nice command does not return an error message if you attempt to increase a command's priority without the appropriate authority. Instead, the command's priority is not changed, and the system starts the command as it normally would.
The nice value is used by the system to calculate the current priority of a running process. Use the ps command with the -l flag to view a command's nice value. The nice value appears under the NI heading in the ps command output.
Note: The csh command contains a built-in command named nice. The /usr/bin/nice command and the csh command's nice command do not necessarily work the same way. For information on the csh command's nice command, see the csh command.
Item | Description |
---|---|
-Increment | Increments a command's priority up or down. You can specify a positive or negative number. Positive increment values reduce priority. Negative increment values increase priority. Only users with root authority can specify a negative increment. If you specify an increment value that would cause the nice value to exceed the range of -20 to 19, the nice value is set to the value of the limit that was exceeded. This flag is equivalent to the -n Increment flag. |
-n Increment | This flag is equivalent to the -Increment flag. |
If the command specified by the Command parameter is started, the exit status of the nice command is the exit status of the command specified by the Command parameter. Otherwise, the nice command exits with one of the following values:
Item | Description |
---|---|
1-125 | An error occurred in the nice command. |
126 | The command specified by the Command parameter was found but could not be invoked. |
127 | The command specified by the Command parameter could not be found. |
nice -n 15 cc -c *.c &
This
example runs the cc command in the background at a lower priority
than the default priority set by the nice command.nice --10 wall <<end
System shutdown in 2 minutes!
end
This example runs the wall command at a higher
priority than all user processes, which slows down everything else
running on the system. The <<end and end portions
of the example define a here document, which uses the text
entered before the end line as standard input for the command.Note: If you do not have root user authority when you run this command, the wall command runs at the normal priority.
nice cc -c *.c
This
example runs the cc command at low priority.Note: This does not run the command in the background. The workstation is not available for doing other things.
nice cc -c *.c &
This
example runs the cc command at low priority in the background.
The workstation is free to run other commands while the cc command
is running. Refer to the "Shells" in AIX® Version 7.1 Operating system and device managementfor more information
on background (asynchronous) processing.Item | Description |
---|---|
/usr/bin/nice | Contains the nice command. |