renice a process with top command in Ubuntu

In this article, we would cover how to renice a process with top command in Ubuntu. A process is an instance of a program. Every process has got a nice value.

Apart from many other things, Linux Kernel do consider nice value when deciding how much CPU access a process should be granted. The default nice value is 0. But, it can range between -20 and 19. When nice value is set to 19 then, it means that the process will have lesser access to the CPU. Whereas, -20 shows higher access to the CPU.

In other words, higher nice value results in less access and lower nice value process has got more CPU access.

Apart from that, we should also know certain rules before we decide to make changes. A normal user can only renice values for processes which the user owns. In addition to, a regular user isn’t allowed to lower down the nice value. For instance, if the user increase nice value of a process to 19. Then, the user can’t bring it back to even 18. That operation just isn’t permitted. As we know that default nice value is set to zero. So, a normal user can’t set negative nice value because the default nice value would have to be then lowered down, which just isn’t permitted.

Whereas, a root user can make all the changes which a normal user can’t do (i.e. changes mentioned above).

With all set, we move forward to how we can achieve the desired outcome next.

renice a process with top command in Ubuntu

If you intend to renice a process with normal user then, issue the following in terminal –

top

or, through a root user use sudo

sudo top

Remember the rules we have discussed above and make changes accordingly. Note down the Process ID (PID) of the process we would like to act on. And, press r (to renice). It would prompt us –

PID to renice

Enter the PID. Thereafter, it would ask us for the value we want to set

Renice PID <XXXX> to value

Enter any integer value between -20 and 19 and press Enter. At this point in time, you can see the changes made to the NI column of the process.

At this stage, you may ask whether the changes I have made will stay even after reboot. We tried that too, and noticed that once we reboot our system any changes made to nice value are lost. Nice value of even an application once closed will be revert to its default next time we launch it.

In conclusion, we have discussed how to renice a process with top command in Ubuntu.

Similar Posts