Linux renice Command: Adjust Process Priority

The renice command in Linux modifies the scheduling priority of already running processes, allowing administrators and users to reallocate CPU resources dynamically without restarting tasks. While the standard nice command sets a process's priority at launch, renice adjusts that priority on the fly. This article details the purpose of the renice command, how the "niceness" scale functions, and how to apply it effectively in a Linux environment.

What is the renice Command?

In Linux, process scheduling determines how much CPU time a process receives. Every process is assigned a "niceness" value, which directly impacts its priority. The renice command allows you to alter this value for any active process identified by its Process ID (PID), Process Group ID (PGID), or the username of the process owner.

The Niceness Scale

The priority scale ranges from -20 to 19:

Permissions and Limitations

Linux enforces permission boundaries on the renice command to maintain system stability:

Basic Syntax and Options

The standard syntax for the command is:

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

Common flags include:

Common Usage Examples

1. Lowering the Priority of a Running Process

To prevent a CPU-heavy background task (such as video encoding or compression) from slowing down the system, increase its nice value:

renice +10 -p 4521

2. Granting High Priority to a Critical Process

If a critical service is struggling due to resource competition, superuser privileges can raise its priority:

sudo renice -n -10 -p 1845

3. Adjusting Multiple Processes at Once

You can alter several PIDs simultaneously:

sudo renice -n 5 -p 1204 1205 1206

4. Adjusting All Processes Owned by a Specific User

To reduce the system impact of all processes run by a specific user:

sudo renice +15 -u john

When to Use renice

The renice command is essential in server management and resource monitoring. Use it when: