Influence a process to run with higher or lower priority using the RENICE command in Linux

Home > Search > Linux commands
  by

The renice command can be used to influence a process that is currently running to run with lower or higher priority. In this example, renice is used to influence gedit to run with higher priority.

[user1@server1 ]# renice gedit

 

Instead of using the name of the process, the process ID (PID) can also be used.

[user1@server1 ]# renice 9844

 

The renice command without any options will increase the renice value by 10, thus influencing the process to run with lower priority. In this example, the NI (nice) value of gedit is 90, which is 10 points more than the standard value of 80.

0 represents the highest priority, and 127 represents the lowest priority. 

[user1@server1 ]# ps -l
F S UID  PID  PPID   C  PRI NI ADDR SZ    WCHAN TTY     TIME       CMD
4 S 0    7521 7516   0  80  0  -    28844 wait  pts/0   00:00:00   bash
0 S 0    9588 7521  22  80  0  -    28844 -     pts/0   00:00:00   ps
0 S 0    9844 7521   0  90  10 -    28844 -     poll_s  00:00:00   gedit

 


Specify amount of influence

The -n or --adjustment option can be used to specify a value. In this example, 5 is specified, which increases the nice value of gedit from 80 to 85.

[user1@server1 ]# renice -n 5 gedit

 

The + or - characters can also be used. In this example, +19 is specified, which increases the nice value of gedit from 80 to 99. Nice does not allow you to influence beyond +19.

[user1@server1 ]# renice -n +19 gedit

 

In this example, -20 is specified, which decreases the nice value of gedit from 80 to 60. Nice does not allow you to influence beyond -20.

[user1@server1 ]# renice -n -20 gedit

 


TOP

Renice can also be used in the top command. In top, press r to adjust the renice value, type the PID of the process, type an integer between -20 and +19, and press enter.

[root@server1 ]# top
top - 21:46:14 up 2 days, 29 min, 2 users, load average: 0.31, 0.40, 0.54
Tasks 160 total, 1 running, 158 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.5 us, 2.2 sy, 1.5 ni, 90.0 id, 4.8 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem:  3067824 total, 1498976 used, 1560456 free, 54168 buffers
KiB Swap: 3104837 total,       0 used, 3104872 free, 85747 cached Mem
PID to renice [default pid = 12345]
PID    User   PR  NI     VIRT     RES     SHR   S  %CPU  %MEM    TIME+   COMMANDS
4594   root   20   0   417768  144754    5803   S   6.0   5.2  0:41:49       Xorg
2488   User1  20   0    92281   85793   84739   S   3.3   4.5  1:04:77 gnome-term
3794   User1  20   0   144384  209193   48473   S   5.7   3.2  0:32:99    firefox
. . .

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments