What is renice?
While `nice` sets the priority when a program **starts**, `renice` is used to change the priority of a program that is **already running**. (Re-Nice)
Key Features
Requires knowing the Process ID (PID) to use.
- Target: Running processes (PID), all processes of a specific user (User), specific group (Group)
- Range: -20 (highest priority/selfish) ~ 19 (lowest priority/yielding). Default is 0.
- Permission Constraints: Normal users can only **decrease** priority (increase the value). Increasing priority (decreasing the value) requires `sudo`.
Main Options (Shell)
`renice` is structured to specify the **value to change (Niceness)** and the **target (PID)**. It is commonly used in the form `renice [value] -p [PID]`.
1. Specifying Priority Value and Target
2. Help
Generated command:
Try combining the commands.
Description:
`renice` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Scenario Examples
Patterns used in practice to reduce system lag or handle urgent tasks.
Lowering Priority of a Specific Process (PID)
renice -n 10 -p 9876
Changes the Niceness value of the process with PID 9876 to 10, making it use fewer resources. (Possible for normal users)
Increasing Priority (Urgent Handling)
sudo renice -n -5 -p 1234
Allocates more CPU to PID 1234. (Assigning a negative value, **sudo required**)
Adjusting All Tasks of a Specific User
sudo renice -n 5 -u user1
Changes the priority of all processes running by `user1` to 5.
Finding PID and Applying Immediately
renice -n 10 -p $(pidof myscript.sh)
An application method that finds the process ID using the `pidof` command and passes it directly.
Installation
renice is a basic command included in the `util-linux` package and is pre-installed on Linux.
Verify Installation
Can be used immediately without separate installation.
Tips & Cautions
Useful Tips
- Permission denied: To increase priority (decrease the value) or modify another user's processes, you must use `sudo`.
- How to Check PID: First, check the PID using `top`, `htop`, or `ps -ef | grep [name]` commands.
- Relative vs. Absolute Values: Depending on some Unix/Linux versions, `renice` might add to the current value (relative) or overwrite the value (absolute). Linux (util-linux) usually sets **absolute values**.