nice — run a command with modified niceness
| Use Case | Command | Description |
|---|---|---|
| Print current niceness | nice |
Displays the current niceness value |
| Run command with increased niceness | nice <command> |
Increments niceness by 10 (default) |
| Run command with specific niceness | nice -n <adjustment> <command> |
Adds ADJUSTMENT to current niceness |
| Run command with lower niceness (privileged) | sudo nice -n -1 <command> |
Requires root privileges |
| Check niceness of a command | nice nice |
Shows current niceness + 10 |
| Relative niceness adjustment | nice -n 3 <command> |
Adds 3 to current niceness (e.g., 10 → 13) |
nice [OPTION]... [COMMAND [ARG]...]
nice prints a process's "niceness", or runs a command with modified niceness. "niceness" affects how favorably the process is scheduled in the system.
If no arguments are given, nice prints the current niceness. Otherwise, nice runs the given COMMAND with its niceness adjusted. By default, its niceness is incremented by 10.
Niceness values range at least from -20 (process has high priority and gets more resources, thus slowing down other processes) through 19 (process has lower priority and runs slowly itself, but has less impact on the speed of other running processes). Some systems may have a wider range of niceness values; conversely, other systems may enforce more restrictive limits. An attempt to set the niceness outside the supported range is treated as an attempt to use the minimum or maximum supported value.
A niceness should not be confused with a scheduling priority, which lets applications determine the order in which threads are scheduled to run. Unlike a priority, a niceness is merely advice to the scheduler, which the scheduler is free to ignore. Also, as a point of terminology, POSIX defines the behavior of nice in terms of a "nice value", which is the non-negative difference between a niceness and the minimum niceness. Though nice conforms to POSIX, its documentation and diagnostics use the term "niceness" for compatibility with historical practice.
COMMAND must not be a special built-in utility.
Due to shell aliases and built-in nice functions, using an unadorned nice interactively or in a script may get you different functionality than that described here. Invoke it via env (i.e., env nice ...) to avoid interference from the shell.
Note to change the "niceness" of an existing process, one needs to use the renice command.
nice is installed only on systems that have the POSIX setpriority function, so portable scripts should not rely on its existence on non-POSIX platforms.
-n ADJUSTMENT, --adjustment=ADJUSTMENT — Add ADJUSTMENT instead of 10 to the command's niceness. If ADJUSTMENT is negative and you lack appropriate privileges, nice issues a warning but otherwise acts as if you specified a zero adjustment.nice also supports an obsolete option syntax -ADJUSTMENT. New scripts should use -n ADJUSTMENT instead.nice itself failsRun a non-interactive program with reduced niceness:
$ nice factor 4611686018427387903
Demonstrate how nice works — default increments by 10:
$ nice
0
$ nice nice
10
$ nice -n 10 nice
10
ADJUSTMENT is relative to current niceness. First nice runs second with niceness 10, then second adds 3:
$ nice nice -n 3 nice
13
Setting niceness beyond supported range uses maximum:
$ nice -n 10000000000 nice
19
Only a privileged user may run a process with lower niceness:
$ nice -n -1 nice
nice: cannot set niceness: Permission denied
0
$ sudo nice -n -1 nice
-1
Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 09:08 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format