Changing process priorities under Unix

If you run CPU-intensive processes, you should familiarize yourself with the nice and, renice, and pbind commands.

Every process has a nice value in the range from 0 to 39, with 39 being the nicest. Nicer processes tend to yield the CPU to less nice processes. By default, user processes start with a nice value of 20. You can see the current nice value of a process in the NI column of a ps listing.

The nice command starts a process with a non-default nice value. There are two versions of the nice command: one built in to the csh, and one in /usr/bin/nice.

If you use the csh (or tcsh, bash), the syntax is:

n is 20 less than the nice value to be used to run command.

If you use some other shell, you will use /usr/bin/nice, which has the syntax:

Again, n is 20 less than the nice value to be used to run command.

The renice command, located in /usr/bin/renice (/usr/ucb/renice for Solaris), changes the nice value of a process already running. It's syntax is:

n is 20 less than the new nice value. pid is the process ID.

Users can only affect the nice value of processes which they own. They cannot start processes with nice values less than 20, nor can they lower the nice values of their processes after they've raised them.