renice

On this page 7

renice is the Linux command that changes the nice value of a process that is already running, which in turn changes how the kernel scheduler weighs that process against others when it distributes CPU time. Where the related nice command sets a priority at launch, renice adjusts it afterward, by process ID, process group or user.

In the management of Linux processes, renice is a low-risk, reversible tuning tool. It does not pause, kill or isolate anything; it only shifts the relative share of processor time a task receives when the CPU is contended. On an idle system, a reniced process runs exactly as fast as before.

How renice adjusts scheduling weight

renice works by calling the setpriority() system call, which writes a new nice value into the kernel’s record of the target task. Nice values range from -20 (highest priority) to 19 (lowest priority), with 0 as the default for ordinary processes. A higher number means the process is “nicer” to others and yields more CPU time.

Under the Completely Fair Scheduler and its successor, the EEVDF scheduler, each nice level maps to a load weight. Nice 0 corresponds to a weight of 1024, and every step changes the weight by roughly 25 percent, so one nice level shifts CPU share by about 10 percentage points between two competing CPU-bound tasks. The scale is multiplicative: a task at nice 0 competing with one at nice 5 receives about three times as much CPU time.

The table below shows how selected nice values translate into scheduler weights and practical effect.

Nice valueLoad weightPractical meaning
-2088761Maximum priority, reserved for critical tasks
-109548Strongly favored, needs root
01024Default for most processes
10110Background work, yields readily
1915Runs mainly when the CPU is otherwise idle
Selected nice values and their scheduler weights

Because the effect is relative, not absolute, renice never guarantees a fixed percentage of CPU. A process at nice 19 still receives all available CPU time if nothing else is runnable.

renice syntax, targets and permissions

The modern util-linux form is renice -n <value> -p <pid>, where -n sets the new value (or, in some versions, an increment) and the target selector decides what is changed. Older scripts often use the positional form renice 10 1234, which still works on most distributions.

OptionTargetTypical use
-pIndividual process IDsAdjust one known task
-gProcess group IDAdjust a shell pipeline or job together
-uAll processes of a userDeprioritize a batch account
renice target selectors

Permissions follow a strict asymmetry. Unprivileged users can only raise the nice value of their own processes, which lowers priority. Lowering a nice value requires root or the CAP_SYS_NICE capability, unless the administrator grants headroom through the RLIMIT_NICE resource limit, usually configured in /etc/security/limits.conf and visible through ulimit -e.

An important detail concerns threads. On Linux, nice values are a per-thread attribute, so renice -p applied to a process ID adjusts only the thread whose ID matches it. To change every thread of a multithreaded program, administrators iterate over the thread IDs listed in /proc/<pid>/task/.

renice is one of several mechanisms that influence how a Linux process competes for resources, and each covers a different dimension. The following comparison helps choose the right tool.

ToolWhat it controlsWhen it appliesScope
niceCPU weightAt process startOne new process
reniceCPU weightWhile runningPID, group or user
ioniceDisk I/O class and priorityStart or runningOne process
chrtReal-time policy and priorityStart or runningOne process
tasksetCPU affinityStart or runningOne process
cgroupsCPU, memory and I/O quotasPersistentGroups of processes
renice versus neighboring controls

The key distinction is that renice operates only within the normal scheduling class (SCHED_OTHER, also SCHED_BATCH). Real-time tasks under SCHED_FIFO or SCHED_RR ignore nice values entirely and are managed with chrt. Where renice offers soft, proportional influence, a cgroup CPU limit imposes a hard ceiling that holds even on an idle machine.

Practical use and choosing a nice value

Administrators typically reach for renice when a long-running job is already consuming CPU and restarting it would waste work. The decision table below summarizes common situations.

SituationRecommended actionReason
Compile job slows interactive shellsrenice to 10-15Keeps the build running while restoring responsiveness
Backup script competes with a databaserenice to 19 and add ioniceBackups are usually limited by disk, not CPU
Critical service starved under loadrenice to -5 as rootSmall boosts avoid starving system daemons
Runaway user accountrenice -n 19 -u the accountContains impact without killing sessions
Permanent policy neededUse cgroups or systemd Nice=renice changes are lost on restart
Choosing a renice strategy

Before acting, the current value can be read in the NI column of top or with ps -o pid,ni,comm. Inside top, the r key performs a renice interactively. Child processes inherit the nice value at fork, so reniced parents pass their priority to new children, though existing children keep their own setting.

Limitations and common mistakes with renice

renice is frequently expected to do more than it can. Its influence is limited to CPU contention, and several pitfalls catch even experienced administrators.

  • No effect on an idle CPU: a reniced task runs at full speed whenever there is spare capacity.
  • Disk and memory are untouched: an I/O-bound process barely slows down; ionice or cgroup I/O limits are needed instead.
  • Autogroup can blunt the effect: with CONFIG_SCHED_AUTOGROUP on desktop systems, nice values compare mainly within one session, so renicing across terminals may change little.
  • Irreversible for normal users: after raising a nice value, an unprivileged user cannot lower it back without RLIMIT_NICE headroom.
  • Aggressive negative values are risky: renicing a heavy job to -20 can starve the shell and SSH daemon needed to recover the system.

The short version

Think of the processor as a single checkout counter and every running program as a customer. renice lets an administrator tell the cashier that a particular customer is less urgent or more urgent than before, without asking anyone to leave the line.

A program made “nicer” with renice does not stop or break. It simply steps aside more often when others need the processor. When nobody else is waiting, it still gets served at full speed. Only an administrator can move a program ahead; ordinary users can only let their own programs wait longer.

Where it makes a difference

A data engineer starts a video transcoding job on a shared eight-core Linux server that also hosts a web application. Within minutes, the transcoder saturates every core, and page response times climb from about 200 milliseconds to more than two seconds.

Restarting the job would discard forty minutes of work, so the engineer finds its process ID with pgrep ffmpeg and runs renice -n 15 -p on the main process and each of its worker threads listed under /proc. The transcoder keeps using spare CPU, but the web server’s request handlers, still at nice 0, now win most scheduling decisions.

Response times return to roughly 250 milliseconds within a minute, and the transcoding job finishes about twenty percent later than planned. The team later adds Nice=15 to the job’s systemd unit so the policy applies automatically on the next run.