renice – Modify the scheduling priority of a running process

The renice command is used to modify the scheduling priority of a running process. It allows you to change the priority of a process to make it run faster or slower, depending on your needs. The priority of a process determines how much CPU time it gets compared to other processes running on the system. By default, all processes are given a priority of 0, but you can use the renice command to change this value.

Overview

The syntax of the renice command is as follows:

renice [-n] priority [-g|-p|-u] identifier [identifier...]

Where:

  • -n specifies the increment or decrement value of the priority. A positive value increases the priority, while a negative value decreases it.
  • priority is the new priority value you want to set for the process. The value can range from -20 (highest priority) to 19 (lowest priority), with 0 being the default priority.
  • -g, -p, or -u specifies the type of identifier you want to use to identify the process. You can use any one of these options:
    • -g to identify the process group ID.
    • -p to identify the process ID.
    • -u to identify the user ID.

Here are some examples of using the renice command:

To increase the priority of a process with ID 1234 by 5:

renice +5 -p 1234

To decrease the priority of all processes owned by user ‘john’ by 2:

renice -2 -u john

To increase the priority of all processes in process group 5678 by 3:

renice +3 -g 5678

Options

Here are the available options for the renice command:

Option Description
-n Specifies the increment or decrement value of the priority.
-g Identifies the process group ID.
-p Identifies the process ID.
-u Identifies the user ID.

Troubleshooting tips

  • If you get an error message that says “operation not permitted”, you may not have sufficient privileges to modify the priority of the process. Try running the command as root or with sudo.
  • Be careful when changing the priority of critical system processes, as this can cause instability or crashes.

Notes

  • The renice command only affects the CPU scheduling priority of a process, not its I/O or memory priority.
  • The priority values range from -20 (highest priority) to 19 (lowest priority), with 0 being the default priority. Negative values indicate higher priority, while positive values indicate lower priority.