December 5, 2026

Linux nice and renice: How Much CPU a Nice Value Really Buys

A CPU heatsink and fan on an open motherboard

Two identical programs, each an endless loop, were forced to share one CPU core for ten seconds. At equal priority they split it 50.0 to 50.0. With one of them started at nice 19, the lowest priority Linux offers, the split became 98.6 to 1.4. Then the same nice-19 loop was launched from a separate login session, and the split went straight back to 50.0 to 50.0, as if the nice value had never been set. All three results came from the same machine within a few minutes. The first two are what most guides describe. The third is the reason nice sometimes seems to do nothing at all.

Video: Learn Linux TV on YouTube

What a nice value is

The range

The sched(7) manual gives the scale: “On modern Linux, the range is -20 (high priority) to +19 (low priority).” A process that’s “nice” to others gives up CPU time. Every ordinary process starts at 0 unless it inherits something else from its parent.

What it applies to

Nice values govern processes under the normal scheduling policies, which the manual names as “SCHED_OTHER and SCHED_BATCH.” Real-time policies ignore them. Nice also changes nothing when a CPU is idle: a lone nice-19 process on a quiet machine still gets 100 percent of a core. It only matters when processes compete.

The commands

nice -n 10 command starts a program at nice 10. renice -n 10 -p PID changes a running one. The renice manual describes it simply: “renice alters the scheduling priority of one or more running processes.” The same page notes that -g targets process groups and -u targets every process owned by a user.

Water flows from brown plastic pipes against a blue sky

The test

Two loops on one core

Each test ran two copies of a one-line Bash loop, while :; do :; done, both pinned to the same CPU with taskset -c 0 so they had to share it. After a one-second settle, the script read each process’s CPU time from /proc/PID/stat, waited ten seconds, and read it again. The difference showed exactly how the scheduler had divided the core.

What ps showed

ps -o pid,ni,pri,stat confirmed each setup. A nice-10 loop listed NI 10 and status RN, where the N marks a low-priority process. The PRI column moved the opposite way from NI: 19 at nice 0, 9 at nice 10, 0 at nice 19. Different tools print priority on different scales, which is one reason the numbers confuse people.

The results

Measured shares

Setup Loop A Loop B
nice 0 vs nice 0 50.0% 50.0%
nice 0 vs nice 5 75.4% 24.6%
nice 0 vs nice 10 90.3% 9.7%
nice 0 vs nice 19 98.6% 1.4%
nice −10 vs nice 0 90.3% 9.7%

Where the numbers come from

The Linux scheduler turns each nice value into a weight, and CPU time is divided in proportion to the weights. The table lives in the kernel source, in kernel/sched/core.c (v6.12 shown here), as sched_prio_to_weight. Nice 0 has weight 1024. Nice 5 is 335, nice 10 is 110, nice 19 is 15, and nice −10 is 9548.

The arithmetic matches the measurements. 1024 ÷ (1024 + 335) is 75.3 percent. 1024 ÷ (1024 + 110) is 90.3 percent. 1024 ÷ (1024 + 15) is 98.6 percent. The nice −10 case landed on the same 90.3 percent as nice 0 versus 10, because 9548 ÷ 1024 is almost exactly the same ratio as 1024 ÷ 110. Only the difference between two nice values matters, not where they sit on the scale.

The 10 percent rule

A comment above the table explains the design: “Nice levels are multiplicative, with a gentle 10% change for every nice level changed.” Each step multiplies the weight by about 1.25, so a gap of one nice level shifts roughly 10 percent of CPU time between two busy tasks, and the gaps compound.

Small gold balance scale on colorful wood

The session surprise

Autogroups

The 50-50 result with nice 19 came from starting each loop with setsid, which gives it a new session, the same thing that happens when a new terminal window opens. On many desktop systems, a kernel feature called autogroup is turned on, and it was here: /proc/sys/kernel/sched_autogroup_enabled read 1. The sched(7) manual explains: “A new autogroup is created when a new session is created via setsid(2),” and the CPU is shared fairly between groups first. A nice value “has an effect only for scheduling relative to other processes executed in the same session.”

What that looked like

Reading /proc/PID/autogroup for the two loops showed /autogroup-462 nice 0 and /autogroup-463 nice 0. Two groups, each at nice 0, so each got half the core. The nice 19 on the process inside the second group only mattered against other processes in that same group, and there weren’t any.

Two ways around it

The manual says the autogroup file accepts “a number in the “nice” range” to set the whole group’s priority. Writing 19 to /proc/PID/autogroup for the second loop’s group changed its line to /autogroup-467 nice 19, and the split became 98.6 to 1.4. Alternatively, writing 0 to /proc/sys/kernel/sched_autogroup_enabled turns the feature off; with it off, the plain nice -n 19 loop in its own session dropped to 1.4 percent again. The test restored the setting to 1 afterward.

renice on a running process

Live change

Two loops started at nice 0. Then one was reniced:

$ renice -n 10 -p 12024
12024 (process ID) old priority 0, new priority 10

Over the next eight seconds, the reniced loop got 9.7 percent of the core, the same as if it had started at nice 10. The change takes effect immediately; nothing has to restart.

Who can do what

As the unprivileged nobody user, raising a process’s nice value worked: old priority 0, new priority 5. Trying to bring it back to 0 failed with Permission denied, and so did nice -n -5. The renice manual states the rule: “an unprivileged user can only increase the “nice value”,” while the superuser “may alter the priority of any process and set the priority to any value in the range -20 to 19.” Lowering priority is a one-way door without root. Even the owner of a process can’t undo their own renice. The practical upshot: a job reniced by mistake stays slow until an administrator steps in, so it’s worth checking the number before pressing Enter.

Office interior visible through large glass windows at night

Services, cron jobs and the same group problem

Setting nice in systemd

For a job that runs as a systemd service or timer, the priority belongs in the unit file rather than in a wrapper script. The systemd.exec manual describes Nice= as setting “the default nice level (scheduling priority) for executed processes,” and it “Takes an integer between -20 (highest priority) and 19 (lowest priority).” One line, Nice=15, in the [Service] section of a backup unit does the same job as prefixing every command with nice -n 15.

Why a niced service can still compete

systemd places each service in its own control group, and that brings back the grouping effect the autogroup tests showed. The systemd.resource-control manual explains that with CPUWeight=, “The available CPU time is split up among all units within one slice relative to their CPU time weight,” and that the kernel default weight is 100. Units are weighed against units first, and nice values then divide each unit’s share among its own processes. A service at Nice=19 competing with a busy process in a different unit may not slow down at all, for the same reason the nice-19 loop in its own session held on to half the core. For a service, CPUWeight= set lower than 100 is the setting that lowers its share against everything else.

Cron

Jobs started by cron inherit cron’s nice value, normally 0. Prefixing the command in the crontab with nice -n 10 is the simple fix, and on systems where cron jobs land in their own sessions, the autogroup caveat above applies to them too.

When nice is the right tool

Good fits

Long background jobs that would otherwise compete with interactive work: compiling, compressing archives, video encoding, backups, indexing. Starting these at nice 10 to 19 costs them almost nothing on an idle machine and keeps the desktop or server responsive when something else needs the CPU.

What it doesn’t touch

Nice affects CPU scheduling only. A low-priority backup can still saturate a disk or the network. Disk I/O has its own priority tool, ionice, and only some I/O schedulers honor it. Memory use is unaffected entirely.

Checking it worked

ps -o pid,ni,comm -p PID shows the nice value. cat /proc/PID/autogroup shows which group the process is in and that group’s own nice value. If a niced job still takes half the CPU, the autogroup line is the first place to look.

Sources

  • sched(7) manual page, man7.org: https://man7.org/linux/man-pages/man7/sched.7.html
  • renice(1) manual page, man7.org: https://man7.org/linux/man-pages/man1/renice.1.html
  • systemd.exec manual: https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html
  • systemd.resource-control manual: https://www.freedesktop.org/software/systemd/man/latest/systemd.resource-control.html
  • Linux kernel source, kernel/sched/core.c (v6.12), sched_prio_to_weight: https://github.com/torvalds/linux/blob/v6.12/kernel/sched/core.c

920 Posts

Peter Kalafatis writes and edits X9M8. He holds a bachelor's degree from LIU Post and a master's in Media Studies from The New School, with academic work in the philosophy of science, human behavior, AI, and memetics.

View All Posts

Leave a Reply

Your email address will not be published. Required fields are marked *