Linux process: priority
Let background work take a smaller turn
A computer's processor (CPU) works through instructions for running programs. When many programs are ready at once, Linux shares CPU time among them. The nice value lets an ordinary task be more or less favored when it competes for that time. It is useful when a long report or other background task should yield more readily to interactive work.
For example, start a report generator with a higher nice value:
nice -n 10 ./generate-report
On Linux, the usual nice range is -20 to +19, with 0 as the conventional starting point. A higher value is “nicer” to other work and usually means less scheduling weight; a lower value gives the task more favorable treatment. The value changes relative competition, not a fixed share of CPU time. It does not reserve a processor, set a deadline, limit memory or disk activity, or solve a machine that is overloaded.
Change a running task
GNU and common Linux versions of nice treat -n as an adjustment to the inherited value. If you omit the adjustment, it normally adds 10. A task that inherits nice 0 and starts with -n 10 therefore starts at 10. Check the installed manual if a script must run on another Unix system, since command behavior can vary.
For a process that is already running, first check its process ID (PID), the number Linux uses to identify it, and its current state. On systems with procps, ps -o pid,ni,pri,cls,cmd -p 1234 shows the PID, nice value (NI), displayed scheduling priority (PRI), scheduling class, and command for PID 1234. Use renice 10 -p 1234 to set a new value. The renice from util-linux treats this as an absolute value by default; its relative mode must be requested explicitly. Compare the NI value before and after the change.
An ordinary user can normally raise the nice value, making the task less favored. Lowering the value to give it more CPU preference needs suitable privilege or a resource limit. If permission is denied, check the account and the system's scheduling policy before asking for more access.
Keep other priority controls distinct
Linux records nice values per thread, even though POSIX describes nice as process-wide. A multithreaded program can therefore have threads with different nice values; inspect them individually if the program's CPU use is surprising. The PRI display from ps is not the same field as NI and should not be read as the nice value.
Real-time scheduling uses different controls. Tools such as chrt and the sched_setscheduler API set policies including SCHED_FIFO and SCHED_RR. Changing nice does not make a task real-time. Real-time priority can require privileges that an ordinary account does not have, and it has different effects from adjusting the nice value.





