How to change nice value of process in linux?

In the “top” command, you can change the nice value of a process in linux interactively. The nice value (also known as the “niceness”) is a parameter that affects the scheduling priority of a process. A lower nice value means higher priority.

Here’s how you can change the nice value of a process using “top”:

1. Start the “top” command by typing “top” in your terminal.

2. Locate the process for which you want to change the nice value.

3. Press “r” to enter the renice command mode.

4. You will be prompted to enter the PID (Process ID) for the process whose nice value you want to change. Type the PID and press Enter.

5. You will be prompted to enter the new nice value. The range typically goes from -20 to 19, where -20 is the highest priority and 19 is the lowest priority. Enter the desired nice value and press Enter.

6. Verify that the nice value has been changed by checking the process list.

7. Press “q” to exit “top”.

Alternatively, you can use the “renice” command directly from the terminal without entering the “top” command. The basic syntax for “renice” is as follows:

renice priority -p PID

For example, to increase the priority of a process with PID 1234, you could use:

sudo renice -n -6 -p 1156

In this example, the nice value is set to -5, indicating a higher priority.

Note:

Changing the nice value of a process usually requires superuser privileges, so you might need to use “sudo” or be logged in as the root user.

Click Here!!! to learn more about “top” command and it’s features.

How do you feel about this post? Drop your comments below..