nice — Run a command with adjusted priority
Linux / Service and process management / nice.html
Starts a command with an adjusted scheduling priority.
Basic Information
| Command Name | nice |
|---|---|
| One-line Introduction | Starts a command with an adjusted scheduling priority. |
| Provided by | GNU coreutils (installed by default) |
| Official Documentation | https://man7.org/linux/man-pages/man1/nice.1.html |
| Supported Operating Systems | Linux, macOS, BSD |
| Installation Status | Installed by default (no separate installation needed) |
| Category | Linux service and process management (tags: Process and resource management (tags: priority, scheduling, load)) |
What is this command?
nice adjusts the nice value that determines how eagerly a process competes for CPU.
Higher values yield more to other tasks, which suits heavy background jobs.
What problems does it solve?
- Run heavy compression or backup at low priority.
- Keep builds from disturbing interactive work.
- Soften the impact of overnight batch jobs.
- Defer low-urgency work.
Key features
Run with a priority
The -n option sets the nice value for the command.
- When to use: When starting a heavy background job
- What you get: A process running at lower priority
- Limitations: Unprivileged users can only raise the value
Current value
Without a command it prints the current nice value.
- When to use: When checking the inherited priority
- What you get: Current nice value
- Limitations: Other processes need another tool
Adjustment range
Negative values need privileges; 19 is the lowest priority.
- When to use: When reasoning about the priority scale
- What you get: Understanding of the usable range
- Limitations: Smaller values mean higher priority
Installation and usage
Check whether it is installed
nice --version
apt install coreutils # usually already present
Real-world examples
Low priority run
Run compression at low priority.
# Run compression with a low priority
nice -n 15 tar -czf backup.tar.gz /srv/data
Check value
Show the current nice value.
# Print the current nice value
nice
Slightly lower
Lower from the default 0 to 10.
# Increase the nice value by 10
nice -n 10 make -j4