Linux nice command

Updated: 05/04/2019 by Computer Hope
nice command

On Unix-like operating systems, the nice command runs a command with a modified scheduling priority.

This page covers the GNU/Linux version of nice.

Description

nice runs command COMMAND with an adjusted "niceness", which affects process scheduling. A process with a lower niceness value is given higher priority and more CPU time. A process with a higher niceness value (a "nicer" process) is given a lower priority and less CPU time, freeing up resources for processes that are more demanding.

Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process).

With no COMMAND, nice prints the current niceness level.

Syntax

nice [OPTION] [COMMAND [ARG]...]

Options

-nN, --adjustment=N Add integer N to the niceness (default is 10).
--help Display a help message and exit.
--version Output version information and exit.

Examples

nice

Displays the default niceness level of new processes; this is commonly zero, so the output would probably look like this:

0
nice -n13 pico myfile.txt

Runs the pico command on myfile.txt with a niceness increment of 13. Since we already saw the default niceness level was zero, this runs pico with a niceness level of zero plus 13, which is 13. As a result, pico can use CPU resources with a higher priority than any process running with a niceness level greater than 14, but has a lower priority than processes with a value less than 14.

Effectively, this tells the system to treat pico as a low-priority process, but not the lowest.

csh — The C shell command interpreter.
ksh — The Korn shell command interpreter.
nohup — Instruct a command to continue running even if the session is disconnected or the user logs out.
priocntl — Display or set scheduling parameters of a processes under Solaris.
sh — The Bourne shell command interpreter.