Monday 24 April 2017

renice command usage and examples

renice

Changing the priority of an already running process can be performed by renice command. renice command is very much similar to the nice command in terms of priority , however it does differ in terms of arguments. You can also give username, group name in renice command as a parameter. But the process can be set with priority range only from -20 to 19. A process with the nice value of -20 is considered to be on top of the priority. And a process with nice value of 19 is considered to be low on the priority list. The default niceness for processes is inherited from its parent process and is usually 0. The process priority can be seen by running one of the following commands

ps –al
ps -o pid,comm,nice -p actual_pid
top

The column that starts with "NI" shows the nice value i.e. the priority of the process. Normal users can only decrease the process priority. However root user can increase/decrease all process's priority. 

Syntax
renice [-n] priority [-p pid] [-g grp_name] [-u user_name]

Some of the examples are shown below:

Example
renice -4 -p 7853

This changes the nice value of the process id 7853 to -4, which will in turn increase its priority over other processes.

Example
renice 11 -p 7853

The above command will set the priority of the process id 7853 to 11.
In this case there is no dash (minus) for command option when specifying the nice value.

Example
renice 15 -p 7853 -u flash

The above command will set the priority of the process id 7853 to 15, and all the process owned by user “flash“to the priority of 15.

Example
renice 14 -g superhero

This changes the nice value of the all process owned by the group " superhero " to 14.

Example
renice 16 -u flash,batman

This will set all process owned by " flash "," batman" to 16.

No comments:

Post a Comment