“renice” Command Usage Examples in Linux

«
»

This tutorial explains Linux “renice” command, options and its usage with examples.

renice – alter priority of running processes.

DESCRIPTION

advertisement

Every running process in Unix has a priority assigned to it.

You can change the process priority using nice and renice utility. Nice command will launch a process with an user defined scheduling priority. Renice alters the scheduling priority of one or more running processes. The following who parameters are interpreted as process ID’s, process group ID’s, or user names. Renice ‘ing a process group causes all processes in the process group to have their scheduling priority altered. Renice ‘ing a user causes all processes owned by the user to have their scheduling priority altered. By default, the processes to be affected are specified by their process ID’s.

SYNOPSIS

renice priority [ -n Increment ][[-p ] pid … ] [[-g ] pgrp … ] [[-u ] user … ]

advertisement

OPTIONS :

-n Increment
Specifies the number to add to the nice value of the process. The value of Increment can only be a decimal integer from -20 to 20. Positive increment values cause a lower nice value. Negative increment values require appropriate privileges and cause a higher nice value.
-g
Force who parameters to be interpreted as process group ID’s.
-u
Force the who parameters to be interpreted as user names.
-p
Resets the who interpretation to be (the default) process ID’s.

EXAMPLES

1. The following will change nice value of process 2243 to 19

# renice 19 2243

2. This would change the priority of process ID’s 987 and 32, and all processes owned by users daemon and root

advertisement
# renice +1 987 -u daemon root -p 32

Note: The specified Increment changes the priority of a process in the following ways:

1 to 20 :- Runs the specified processes slower than the base priority.
0 :- Sets priority of the specified processes to the base scheduling priority.
-20 to -1 :- Runs the specified processes quicker than the base priority.

3. To alter the system scheduling priority so that group IDs 324 and 76 have higher scheduling priorities (if the user has the appropriate privileges to do so), enter:

advertisement
# renice -n -4 -g 324 76

Note:
(1) Users can only change the nice value of processes which they own.
(2) User cannot start processes with nice values less than 20.
(3) User cannot lower the nice values of their processes after they’ve raised them.
(4) As usual root has full access to renice command.

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn