O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

nice — stdin  stdout  - file  -- opt  --help  --version

Synopsis

nice [-level] command_line

When invoking a system-intensive program, you can be nice to the other processes (and users) by lowering its priority. That’s what the nice command is for: it sets a nice level (an amount of “niceness”) for a process so it gets less attention from the Linux process scheduler.[15] Here’s an example of setting a big job to run at nice level 7:

$ nice −7 sort VeryLargeFile > outfile

If you run nice without a level, 10 is used. Normal processes (run without nice) run at level zero, which you can see by running nice with no arguments:

$ nice
0

The superuser can also lower the nice level, increasing a process’s priority:

# nice --10 myprogram

(Yes, that’s “dash negative 10”.) To see the nice levels of your jobs, use ps and look at the “NI” column:

$ ps -o pid,user,args,nice

[15] This is called “nicing” the process. You’ll hear the term used as a verb: “That process was niced to 12.”

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required