Hack 101. Renice Command Examples
by Ramesh
Renice alters the scheduling priority of a running process.
How to decrease the priority of a running process? (Increase nice)
In the example below, an existing shell-script is running at nice value of 10. (6th column in the ps output)
- $ ps axl | grep nice-test
- 0 509 13245 13216 30 10 5244 968 wait SN pts/1 0:00 /bin/bash ./nice-test.sh
To increase the nice value (thus reducing the priority), execute the renice command as shown below.
- $ renice 16 -p 13245
- 13245: old priority 10, new priority 16
- $ ps axl | grep nice-test
- 0 509 13245 13216 36 16 5244 968 wait SN pts/1 0:00 /bin/bash ./nice-test.sh
[Note: Now, the 6th column of the nice-test.sh (PID 13245) shows the new nice value of 16.]
How to increase the priority of a running process? (Decrease nice)
In the example below, an existing shell-script is running at a nice value of 10. (6th column in the ps output)
- $ ps axl | grep nice-test
- 0 509 13254 13216 30 10 4412 968 wait SN pts/1 0:00 /bin/bash ./nice-test.sh
In increase the priority, give a lower nice value as shown below. However, only root can increase the priority of a running process, else you’ll get the following error message.
- $ renice 5 -p 13254
- renice: 13254: setpriority: Permission denied
- Login as root to increase the priority of a running process
- $ su -
- # renice 5 -p 13254
- 13254: old priority 10, new priority 5
- # ps axl | grep nice-test
- 0 509 13254 13216 25 5 4412 968 wait SN pts/1 0:00 /bin/bash ./nice-test.sh
[Note: The 6th column now shows a lower nice value of 5 (increased priority)]