Saturday, October 24, 2009

Nice Command

`Nice' prints or modifies a process's "niceness", a parameter that affects whether the process is scheduled favorably.
Synopsis:

nice [OPTION]... [COMMAND [ARG]...]

If no arguments are given, `nice' prints the current niceness. Otherwise, `nice' runs the given COMMAND with its niceness adjusted. By default, its niceness is incremented by 10.

Nicenesses range at least from -20 (resulting in the most favorable scheduling) through 19 (the least favorable). Some systems may have a wider range of nicenesses; An attempt to set the niceness outside the supported range is treated as an attempt to use the minimum or maximum supported value.

A niceness should not be confused with a scheduling priority, which lets applications determine the order in which threads are scheduled to run. Unlike a priority, niceness is merely advice to the scheduler, which the scheduler is free to ignore.

Try opening a file with different nice values and notice the delay during opening the file to feel the usage of niceness value:

[root@localhost ]# nice -n 18 vi unused.c
[root@localhost ]# nice -n -18 vim unused.c

It is sometimes useful to run a non-interactive program with reduced niceness. Say if you would like to find the factors of numbers 50, 90, 999 by the command factor, you can use the nice command with + value for niceness.

No comments:

Post a Comment