When to use nice
Use nice to start a command with an adjusted CPU scheduling preference. It influences competition for CPU time rather than setting a hard CPU limit, and it does not directly limit memory or disk activity.
Syntax
nice [-n INCREMENT] COMMAND…Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Check current value
niceThe current CPU priority adjustment is displayed without starting another workload.
Start background work with lower priority
nice -n 10 sha256sum ./archive.tar.gzChecksum calculation starts with a lower CPU scheduling preference.
Run script with lower priority
nice -n 15 ./report.shThe report script starts with an even lower CPU preference, provided the script exists and is executable.
Notes and limitations
- A higher nice value means lower CPU scheduling priority. Lowering the value usually requires privileges.
- nice does not impose a hard CPU limit or limit I/O.
Common questions and troubleshooting
Does a larger nice value mean higher priority?
On typical Linux scheduling it means lower priority. Negative values request higher priority and generally require additional privilege.
Will nice prevent a task from using all idle CPU?
No. A low-priority task can still use otherwise idle CPU. Use resource-control facilities when a hard quota is required.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man nice.