Modifying the priority with the renice command

The renice command alters the nice value, and thus the priority, of one or more processes that are already running. The processes are identified either by process ID, process group ID, or the name of the user who owns the processes.

The renice command cannot be used on fixed-priority processes. A non-root user can specify a value to be added to, but not subtracted from the nice value of one or more running processes. The modification is done to the nice values of the processes. The priority of these processes is still non-fixed. Only the root user can use the renice command to alter the priority value within the range of -20 to 20, or subtract from the nice value of one or more running processes.

To continue the example, use the renice command to alter the nice value of the vmstat process that you started with nice.
# renice -n -5 7568
# ps -lu user1
       F S UID  PID PPID   C PRI NI ADDR    SZ    WCHAN    TTY  TIME CMD
  241801 S 200 7032 7286   0  60 20 1b4c   108           pts/2  0:00 ksh
  200801 S 200 7568 7032   0  60 20 2310    92  5910a58  pts/2  0:00 vmstat
  241801 S 200 8544 6494   0  60 20 154b   108           pts/0  0:00 ksh
Now the process is running at a more favorable priority that is equal to the other foreground processes. To undo the effects of this, you could issue the following:
# renice -n 5 7568
# ps -lu user1
       F S UID  PID PPID   C PRI NI ADDR    SZ    WCHAN    TTY  TIME CMD
  241801 S 200 7032 7286   0  60 20 1b4c   108           pts/2  0:00 ksh
  200801 S 200 7568 7032   1  70 25 2310    92  5910a58  pts/2  0:00 vmstat
  241801 S 200 8544 6494   0  60 20 154b   108           pts/0  0:00 ksh

In these examples, the renice command was run by the root user. When run by an ordinary user ID, there are two major limitations to the use of the renice command:

  • Only processes owned by that user ID can be specified.
  • The nice value of the process cannot be decreased, not even to return the process to the default priority after making its priority less favorable with the renice command.