$ run as a normal user# run as root (or with sudo)
The quick answer
Step by step
- Start a job with low priority (line 1) —
nice -n 15 COMMAND. Normal processes have nice 0. - See the nice value (line 2) — the
NIcolumn (also intop). - Change a running process (line 3) —
renice -n 15 -p PID; a whole user:renice -n 10 -u backup. Normal users may only make their own processes nicer (higher number); lowering it needs root. - Disk priority (line 4) —
ionice -c 3= idle class: the process uses the disk only when nobody else does. Start a job with both:nice -n 15 ionice -c 3 rsync -a /data /backup. (ioniceworks with the BFQ and CFQ I/O schedulers; withnone/mq-deadlineuse systemd'sIOWeightor cgroup limits instead.) - For services — in a
systemctl edit backup.serviceoverride:
[Service]
Nice=15
CPUWeight=20
IOWeight=20CPUWeight (default 100) shares CPU between cgroups under load; it works for the whole service with all its child processes.
- Nice does not limit — a nice-19 process still uses 100 % CPU if nobody else needs it. For a hard limit use
CPUQuota=50%(systemd) or container limits. - Do not make important things "less nice" by habit — negative values for one app can starve the system (SSH, monitoring).
Check that it worked
ps -o pid,ni,comm -p PID shows NI 15; under load top shows the web app getting most of the CPU while the backup still progresses; systemctl show backup.service -p Nice -p CPUWeight shows the new values.
Common problems
| Problem | Cause | Fix |
|---|---|---|
renice: failed to set priority … Permission denied | Lowering the nice value as a normal user. | Use root, or only raise the value. |
| No visible effect | The CPU is not busy, or the bottleneck is disk/memory. | Nice only matters under CPU contention; use ionice/IOWeight for disk. |
ionice has no effect | I/O scheduler ignores priorities. | Check /sys/block/DEV/queue/scheduler; use IOWeight in systemd. |
| Child processes have the old value | renice on one PID only. | renice -g PGID or set it on the service. |
| Job still slows the app | Nice does not cap usage. | CPUQuota= or run the job at night. |
| Value lost after restart | Set with renice by hand. | Put Nice= in the service unit. |
Go further
- Command pages: nice, renice, ps, top.
- Next how-tos: Find out why a server is slow, Limit CPU and memory of a service, Choose a performance profile with tuned, Back up a server with restic.
- Learn it: RHCSA — Priorities, RHCSA — nice, RH134 — renice.
1Which nice value has the highest priority?
−20 is the highest priority, 19 the lowest; normal processes start at 0.
2Does a high nice value limit how much CPU a process can use?
No — it only lets other processes go first; when the CPU is free, a nice process can still use all of it.