HTOP nice level mismatch with the nice command?

12,070

The “nice” value ranges from -20 (top priority, not nice at all to other processes) to 19 (least priority, very nice to others). When you run nice -20 (equivalent to nice -n 20) or sudo nice -n -42 (equivalent to sudo nice --42) or any other value out of bounds, the nice value is moved to the bound.

The red is simply coloring applied to negative values in that column, indicating high-priority (“not nice”) processes. Positive values are green, indicating low-priority (“nice”) processes.

Share:
12,070

Related videos on Youtube

Dominique
Author by

Dominique

Updated on September 18, 2022

Comments

  • Dominique
    Dominique over 1 year

    I executed some commands with nice -20 but in htop the NI appears in red and as 19, why is this?

    screenshot

    • Dominique
      Dominique about 10 years
      Note that I executed a script with parallel and I also used nice -20 on it, as well as commands in the script
    • cristi
      cristi over 8 years
      what was the command you used to set niceness?
    • Cees Timmerman
      Cees Timmerman about 7 years
      nice -20 vi shows as green 20 in htop on MacOS Sierra.
  • Dominique
    Dominique about 10 years
    So since I used nice -20 it defaulted to least priority?
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' about 10 years
    Yes, nice -20 or nice -19 or nice -99999999 means the least priority which is 19.
  • Dominique
    Dominique about 10 years
    So I should use something like nice +20 to get max priority?
  • Rui F Ribeiro
    Rui F Ribeiro over 8 years
    Only root can increase the priority of a process.
  • cristi
    cristi over 8 years
    This is not correct. nice -n -20 should set the niceness ro -20, not +19
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 8 years
    @cristi I'm confused, what is not correct? Are you confusing nice -20 and nice -n -20? nice -20 is equivalent to nice -n 20. Yes, it's a bit confusing to have the - sign switch from being an option marker to a minus sign.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 8 years
    The question stated nice -20, which is the opposite of nice -n 20.
  • cristi
    cristi over 8 years
    Sorry, I thought you said that niceness <-20 will go to 19
  • Cees Timmerman
    Cees Timmerman about 7 years
    @Gilles -n adjusts the Nice value by the amount following it, so nice -n 20 adds, just like nice -20 does (the - denotes a parameter there, not a negative value).
  • Cees Timmerman
    Cees Timmerman about 7 years
    A red value in htop means it's negative, so either the "red 19" was green (as indicated by the Unix nice range), OP used nice -n -20, or MacOS Sierra has different nice and/or htop behavior (-20 to 20 nice values is one).