Welcome to the new Linux Foundation Forum!

confusion about renice command

Hi,

  1. Does the renice +number command increase the niceness to "number" unit or set the niceness to that "number" ?
    For instance, I can't use the command renice +5 process if that process have a nice value set to 10, unless I use sudo. Because this command is going set the nice value to 5 and thus decrease the old value rather than increasing it!

  2. On my machine renice +5 process and renice 5 process do the same. Is that normal ? what's the difference between the two commands ?

  3. Increasing the niceness is supposed to decrease the priority (and vice-versa when decreasing). However, when the niceness is increased we see the priority increased as well in the PRI column of the ps command. What does the PRI column show exactly ?

Thanks.

Comments

  • Hi,

    Does the renice +number command increase the niceness to "number"
    unit or set the niceness to that "number" ?

    Increase.

    For instance, I can't use the command renice +5 process if that process
    have a nice value set to 10, unless I use sudo. Because this command is
    going set the nice value to 5 and thus decrease the old value rather than
    increasing it!

    I didn't understand the details of your test, but if you are increasing the priority of a process, you need to be root or use sudo. You can see that in man renice(1):

    NOTES
    Users other than the superuser may only alter the priority of processes they own. Furthermore, an unprivi‐
    leged user can only increase the nice value'' (i.e., choose a lower priority) and such changes are irre‐ versible unless (since Linux 2.6.12) the user has a suitablenice'' resource limit (see ulimit(1) and getr‐
    limit(2)).

       The superuser may alter the priority of any process and set the priority to any value in the range -20 to  19.
       Useful  priorities  are: 19 (the affected processes will run only when nothing else in the system wants to), 0
       (the ``base'' scheduling priority), anything negative (to make things go very fast).
    

    On my machine renice +5 process and renice 5 process do the same.
    Is that normal ? what's the difference between the two commands ?

    That happens because the niceness of a process (started by you) starts on 0. So, if you add 5 or set to 5, the result will be the same. To help understand how it works, you can use the following:

    1.- Start a process, say gnome-clocks.
    2.- Print basic information of the processes and look at gnome-clocks (or whatever you are testing with):
    ps -eo pid,tid,ni,pri,stat,comm

    3.- See that "NI" and "PRI" indicates for the process.
    4.- Change the niceness of the process.
    5.- Print the information again, and compare. Ask yourself: what happened with the niceness and priority value when adding 7, for example?

    Regards,
    Luis.

Sign In or Register to comment.