System and processes
The nice command
Runs a command with lower priority so it does not hog the CPU. It goes from -20 (highest) to 19 (lowest).
Syntax
nice [-n N] COMANDOMost useful options
-n NSets the priority (10 by default)19The lowest priority: for background jobsCopy-ready examples
$ nice -n 10 sleep 100 & && ps -lLaunch at priority 10 and see it in ps -l$ nice -n 19 sleep 60 &The lowest priorityYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- The higher the number, the lower the priority (the other way round than it looks).
- Only root can go below 0 (give more priority).
- The effect shows in the NI column of ps -l and especially in background jobs.
FAQ
Can I change it later?
Yes, with renice on the PID.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course