Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

renice Command Guide for Changing a Running Process’s Priority

renice changes the niceness of a process that is already running — the mid-flight counterpart to nice.


What is renice, and Why Use It?

The renice command re-adjusts the niceness value of one or more running processes. You specify the target by process ID (-p), by running command name (-u), or by group of processes started by a user (-g). It is the tool you reach for when a program starts first and you change your mind later — a runaway backup that needs to become polite, or an urgent job that deserves more CPU than it currently has.

Why Learn renice?

  • Fix priority mistakes: launched something too greedily? renice brings it back down without restarting it.
  • No restart cost: changing a running process’s priority takes effect instantly — no killing and relaunching.
  • Find it by name: -u targets every process owned by a user, so you do not need to hunt for PIDs first.
  • Pairs with nice: nice at launch time, renice in flight — one concept, two commands.

renice is the mid-flight steering wheel for CPU priority: nice decides where a program starts, renice decides where it ends up.


1. Basic Usage: Change by Process ID

# Lower the priority of PID 1234 (niceness 10 — very polite)
renice -n 10 -p 1234

# Raise the priority (needs root for negative values)
sudo renice -n -5 -p 1234

# Find the PID first if you do not know it
pgrep -f myscript.sh

The -n flag sets the absolute niceness value. Older syntax like renice 10 -p 1234 still works but is deprecated in favor of -n.


2. Change by User or by Process Group

# All processes owned by the user "buildbot"
renice -n 15 -u buildbot

# All processes started by user "alice" — note the % prefix
renice -n 15 -g %alice

# Combine with ps to find candidates first
ps -eo pid,ni,user,comm
  • -u user — every process owned by that user.
  • -g grp — processes in that group; prefix a user name with % to mean “all processes of this user”.

3. Checking the Result

# Show PID, niceness, and command for everything
ps -eo pid,ni,comm

# Confirm one process changed
ps -o pid,ni,cmd -p 1234

The ni column in ps output shows the current niceness — 0 is the default, 19 is the politest.


4. Who Can Do What

ChangeNeeds root?
Lower niceness (make more polite)No — any user may do this to their own processes
Raise niceness within the current rangeUsually yes
Raise niceness below 0Always yes
Touch another user’s processAlways yes

The rule of thumb: you can always make your own programs more polite, but only root can make them greedier.


5. renice vs. nice

nicerenice
WhenBefore the program startsWhile it runs
TargetThe command you launchAn existing process
Syntaxnice -n 10 commandrenice -n 10 -p PID
Restart neededN/ANo
# nice: priority baked in at launch
nice -n 10 ./backup.sh &

# renice: same outcome, but you started the job first
./backup.sh &
renice -n 10 -p $!

Common Pitfalls

  • Forgetting that renice needs a target: unlike nice, it changes something existing — always pass -p, -u, or -g.
  • Negative values need root: renice -n -5 -p 1234 as a normal user silently fails or errors; use sudo.
  • -u matches every process of that user: it is broad by design — double-check with ps -u before renicing.
  • Nice values do not persist: they reset when the program restarts; bake long-term priority into a unit file or wrapper script.

PageWhy It Matters
niceSet priority at launch — the launch-time half of the same idea.
psShow the ni column to see current priorities.
pgrepFind the PIDs you want to re-nice.
topWatch priority-driven scheduling live (r key renices interactively).

renice Cheatsheet

CommandWhat It Does
renice -n 10 -p 1234Make PID 1234 polite.
sudo renice -n -5 -p 1234Make PID 1234 greedy (needs root).
renice -n 15 -u buildbotRe-nice every process owned by a user.
renice -n 15 -g %aliceRe-nice every process started by user alice.
ps -eo pid,ni,commCheck current niceness values.
ps -o pid,ni,cmd -p PIDCheck one process.