$linuxjunkies
>

nice(1)

Run a command with a modified CPU scheduling priority.

UbuntuDebianFedoraArch

Synopsis

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

Description

nice executes a command with an altered scheduling priority, allowing you to run CPU-intensive tasks in the background without starving other processes. By default, it reduces the priority (increases the niceness value) by 10, making the process less aggressive in competing for CPU time.

Niceness values range from -20 (highest priority) to 19 (lowest priority). Only the superuser can use negative niceness values to increase a process's priority.

Common options

FlagWhat it does
-n, --adjustment=NAdd N to the niceness value (default 10); can be negative to increase priority
-10Shorthand for --adjustment=-10; increases priority (superuser only)
--helpDisplay help message and exit
--versionDisplay version information and exit

Examples

Run backup.sh at lower priority (niceness +15), yielding CPU to other tasks

nice -n 15 backup.sh

Search the entire filesystem with default reduced priority (niceness +10)

nice find / -name '*.log' > results.txt

Create a compressed archive in the background at lowest priority (niceness +19)

nice -n 19 tar czf archive.tar.gz /data &

Compile with increased priority (superuser only); useful for important builds

sudo nice -n -5 make -j8

Run a Python script with moderate priority reduction (niceness +5)

nice -n 5 python3 data_processing.py

Run stress test with increased priority (superuser); root can use negative values

nice -10 stress --cpu 4 --timeout 60s

Related commands