Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Processes and Signals

Linux nice and renice commands

Reference for the Linux nice and renice commands: start a program with lower priority, change the priority of a running process, niceness values and permission limits.

Every process has a niceness, a number from -20 to 19 that nudges the scheduler. A higher value means "nicer to other processes": the process gets a smaller share of the CPU when others compete. The default is 0. nice starts a command with a chosen niceness; renice changes it for a process that is already running.

Niceness only matters when the CPU is busy. On an idle machine a nice 19 process runs as fast as any other. It does not affect disk or network priority (see ionice for disk).

Terminal
nice [-n ADJUSTMENT] COMMAND [ARG]...
renice -n PRIORITY [-p PID...] [-g PGID...] [-u USER...]

Try it

Bash Starting a command with a different niceness

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Changing a running process

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
nice [-n N | -N] COMMAND [ARG]...
nice                      # no command: print current niceness
renice [-n] PRIORITY [-g | -p | -u] ID...
Item Description
nice -n N Add N to the current niceness (default N is 10). Negative values need root.
renice -n N Set the niceness to the absolute value N.
renice -p PID The ID is a process ID (the default).
renice -g PGID The ID is a process group.
renice -u USER All processes of that user.

Returns: nice returns the command's status, or 125/126/127 if it could not run it. renice returns non-zero if any change failed.

Edge case: nice -n 5 nice adds to the niceness, not sets it, so nested calls accumulate up to 19.

Usage notes

  • Range. -20 is the highest priority, 19 the lowest. Values beyond are clamped.
  • Privilege. Anyone can make a process nicer; only root (or a user with a raised RLIMIT_NICE) can lower niceness, and an ordinary user can never lower below the value the process has now.
  • nice -n versus renice -n: the first is relative, the second absolute. Reading either error message carefully avoids surprises: nice -n -5 cmd as a normal user fails with a permission message, then runs the command with unchanged priority.
  • Children inherit. A process forked from a nice process starts with the same niceness, so nice on a build tool covers its compiler jobs.
  • Real-time policies (chrt) beat niceness; niceness applies to the normal scheduler only.
  • Good fits. Backups, compression, indexing and batch builds: nice -n 19 tar czf .... Pair with ionice -c3 for I/O-heavy jobs.
  • Seeing it: ps -o pid,ni,comm, top (NI column).