nice(1)
Run a command with a modified CPU scheduling priority.
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
| Flag | What it does |
|---|---|
-n, --adjustment=N | Add N to the niceness value (default 10); can be negative to increase priority |
-10 | Shorthand for --adjustment=-10; increases priority (superuser only) |
--help | Display help message and exit |
--version | Display version information and exit |
Examples
Run backup.sh at lower priority (niceness +15), yielding CPU to other tasks
nice -n 15 backup.shSearch the entire filesystem with default reduced priority (niceness +10)
nice find / -name '*.log' > results.txtCreate 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 -j8Run a Python script with moderate priority reduction (niceness +5)
nice -n 5 python3 data_processing.pyRun stress test with increased priority (superuser); root can use negative values
nice -10 stress --cpu 4 --timeout 60s