Overview
renice is used to dynamically change the nice value of already running processes. A lower nice value means a higher chance of receiving more CPU resources, while a higher value means fewer resources. Regular users can only increase the nice value (lower priority) for their own processes; root privileges are required to decrease the nice value (increase priority).
Key Features
- Nice Value Range: -20 (highest priority) to 19 (lowest priority)
- Root Privileges Required: When decreasing the nice value (increasing priority)
- Regular User Privileges: Only possible when increasing the nice value (decreasing priority)
Key Options
The renice command primarily uses options to specify the nice value to change and the target process.
Specify Priority Value
Specify Target
Generated command:
Try combining the commands.
Description:
`renice` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Various usage examples of the renice command.
Lower Priority of a Specific Process
renice -n 10 -p 12345
Changes the nice value of the process with PID 12345 to 10, thus lowering its priority.
Raise Priority of All Processes for a Specific User (Requires Root Privileges)
sudo renice -n -5 -u myuser
Changes the nice value of all processes owned by the user 'myuser' to -5, thus raising their priority. This operation requires root privileges.
Change Priority of a Specific Process Group
renice -n 5 -g 54321
Changes the nice value of all processes belonging to the process group with PGID 54321 to 5.
Change Priority of the Current Shell
renice -n 15 -p $$
Changes the nice value of the current shell process to 15. $$ represents the PID of the current shell.
Tips & Precautions
Points to note and additional tips when using renice.
Meaning of Nice Values
A lower nice value indicates higher priority, and a higher nice value indicates lower priority. Therefore, -20 is the highest priority, and 19 is the lowest.
- Lower Nice Values (-20 to 0): Higher priority, potential for more CPU resource allocation
- Higher Nice Values (1 to 19): Lower priority, potential for less CPU resource allocation
Permissions
Regular users can only increase the nice value (decrease priority) of their own processes to reduce system load. To decrease the nice value (increase priority) and allocate more resources than other processes, root privileges like `sudo` are required.
- Regular User: Can only increase their own process's nice value (decrease priority)
- Root User: Can change the nice value of all processes (increase/decrease)
Precautions
Setting a very low nice value (high priority) can affect the performance of other critical system processes, so caution is advised. For system stability, it is generally recommended to maintain default values or use it to lower priority unless absolutely necessary.