renice is the command used to alter the priority of a running process. The processes to be affected are specified by their process IDs.
Example:
renice [priority] [PID]
[priority]: Valid range of priorities is -20 to 20, with -20 being the highest priority and 20 being the lowest.
- 0 - the base scheduling priority.
- 19 - the affected processes will run only when nothing else in the system wants to.
- 20 is an acceptable value but will be rounded down to 19.
When the priority is made very negative, the process can not be interrupted. To regain control, the priority must be made greater than 0.
[PID]: Process ID of the process whose priority is to be altered. This can be obtained by using the command ps.
Typical processes whose priority may need to be altered:
- When applications like Matlab or system processes like dtlogin or user programs become run away processes, renice them to a priority of 19.
- Processes that are CPU intensive but not run away, renice them to a priority of 11.
Instead of altering the priority of a process after it has been started, it is possible to invoke the process with a particular priority. This is done using nice.
Example: To invoke Matlab with a priority of +11:
nice +11 matlab
NOTE: When using nice the priority must be specified with a + or - sign.