LinuxCommandLibrary

renice

Adjust running process priority (niceness)

TLDR

Increase/decrease the priority of a running [p]rocess

$ renice -n [3] -p [pid]
copy

Increase/decrease the priority of all processes owned by a [u]ser
$ renice -n [-4] -u [uid|user]
copy

Increase/decrease the priority of all processes that belong to a process [g]roup
$ renice -n [5] -g [process_group]
copy

SYNOPSIS

renice new_priority [[-p] pid ...] [[-g] pgroup ...] [[-u] user ...]
renice [-n increment] [-p | -g | -u] ID...

PARAMETERS

new_priority
    The desired new nice value. Valid range is from -20 (highest priority) to 19 (lowest priority).

-p pid...
    Specifies one or more Process IDs (PIDs) whose nice value will be adjusted. This is the default if no type flag is provided.

-g pgroup...
    Specifies one or more Process Group IDs (PGIDs) whose nice value will be adjusted. All processes within the specified group(s) will be affected.

-u user...
    Specifies one or more User IDs (UIDs) or usernames. All processes owned by the specified user(s) will have their nice value adjusted.

-n increment
    An alternative syntax to specify an increment to the current nice value. For example, -n 5 adds 5 to the current nice value. This option is typically used in conjunction with -p, -g, or -u.

DESCRIPTION

renice alters the scheduling priority of one or more running processes. This priority is known as the "nice value", which ranges from -20 (highest priority) to 19 (lowest priority). A lower nice value means the process gets more CPU time. The command allows users to change the nice value of processes, process groups, or processes owned by specific users. Regular users can only "renice" their own processes to a higher (less favorable) nice value (i.e., increase the nice value or decrease the priority). Root users, however, can change the nice value to any allowed value, including making processes run at a higher priority by decreasing their nice value. This is particularly useful for managing system resources, for instance, by reducing the priority of a CPU-intensive background task to ensure interactive applications remain responsive.

CAVEATS

Only the root user can decrease a process's nice value (i.e., increase its priority). Regular users can only increase a process's nice value (i.e., decrease its priority) for processes they own. Renicing a process only affects its scheduling priority until the system reboots or the process exits. It does not provide persistent priority changes across reboots.

UNDERSTANDING NICE VALUES

The "nice value" is a numerical representation of a process's scheduling priority. In Linux, it ranges from -20 (least "nice," highest priority) to 19 (most "nice," lowest priority). A lower nice value means the process is more likely to receive CPU time from the kernel's scheduler. The term "nice" implies being "nice" to other processes by yielding CPU time; thus, a higher nice value means the process is more willing to share CPU resources.

IMPACT ON SYSTEM PERFORMANCE

Adjusting nice values can significantly impact system responsiveness. By increasing the nice value (decreasing priority) of CPU-intensive background tasks (e.g., video encoding, large compilations), interactive applications like web browsers or text editors can remain smooth and responsive. Conversely, decreasing the nice value (increasing priority) of critical real-time or low-latency applications (e.g., audio processing, scientific simulations) can ensure they receive adequate CPU time, potentially at the expense of other less critical processes.

HISTORY

The renice command has been a standard utility in Unix-like operating systems since early versions of BSD (e.g., 4.0BSD). It provides a simple command-line interface to interact with the kernel's process scheduler, allowing users to fine-tune resource allocation behavior. Its core functionality has remained largely consistent over decades.

SEE ALSO

nice(1), top(1), ps(1), pgrep(1)

Copied to clipboard