Untitled Document
nice Command

The nice command is used to reduce / modify the priprity of a process .nice runs command with nice values, which affects process scheduling. A process with a lower nicen value is given higher priority and more CPU time. A process with a higher nicen value (a "nicer" process) is given a lower priority and less CPU time, freeing up resources for processes which are more demanding.

Nice values range from 1 to 19 . For more details on nice command Go to Chapter - 9

1. Basic Example -

With no command, nice prints the current nice level. this is commonly zero .

   nice 

2. Running jobs with nice levels

Runs the wc  command on shell_progs directory with an niceness increment of 5. Since we already saw that the default niceness level was zero, this runs wc with a niceness level of zero plus 5, which is 5. As a result, wc will be able to use CPU resources with a higher priority than any process running with a niceness level greater than 6, but will have a lower priority than processes with a value less than 6.

Effectively, this tells the system to treat wc as a low-priority process, but not the lowest.

   nice -n 5 wc -l shell_progs 
Untitled Document