Linux and Unix nice command

Quick links

About nice
Syntax
Examples
Related commands
Linux and Unix main page

About nice

Runs a command with a modified scheduling priority.

Syntax

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

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 which 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.

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 an niceness increment of 13. Since we already saw that the default niceness level was zero, this runs pico with a niceness level of zero plus 13, which is 13. As a result, pico will be able to use CPU resources with a higher priority than any process running with a niceness level greater than 14, but will have 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.

Related commands

csh
ksh
nohup
priocntl
sh