DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Controlling processes

Reducing the priority of a process

One of the factors that controls when a process is executed is its ``priority'', which can be manipulated using the nice(C) command. This is useful at the start of a big job such as compressing all the files in a directory, particularly when the speed at which the job completes is not crucial. nice has the following form:

nice -increment command_line

To use the nice command, specify a value between 0 and 39, indicating how low a priority you want the command to have: 39 is the lowest. If you do not specify a priority, nice assumes an increment of 10.

By default, the system processes execute with a nice value of 20. An increment value of 15 would cause command_line to execute at a nice value of 35, that is, towards the lower end of the priority range, where it would receive proportionately less CPU time.

An increment of -10, specified as follows, would increase the priority of the command line to 10:

   $ nice --10 find / -name chapter6.txt -print > out_file
By using nice --10 to run the command line, you ensure that it takes more processor time than the other programs on the system, thereby increasing its execution speed. Increasing the priority of a job above 20 is available only to the root user.

Note that in the C shell, increasing the nice value of a process works in reverse. For example, to run the find command above, you would enter the following:

   $ nice +10 find / -name chapter6.txt -print > out_file

Next topic: Identifying the niceness of a process
Previous topic: Shell signal handling

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005