nice vs renice vs ionice on Linux: CPU and I/O Priority Explained

nice renice ionice linux - custom-nice-featured.png

nice and renice adjust CPU scheduling niceness (−20 to 19). ionice is separate: it classes disk I/O (realtime, best-effort, idle) so a backup does not starve a database on the same disk — a common comparison search on busy VPS hosts.

Related: kill & pkill,
htop,
iostat & vmstat.

nice — start a job softer

Lower priority before the process runs — good for cron backups and reindex jobs.

bashbatch
nice -n 19 tar -czf /backup/site.tgz /var/www
nice -n
new process

renice — running processes

Tune an already-hot PID when killing is too drastic; non-root users can only raise niceness (lower priority).

bashthrottle
renice +10 -p 18432
ps -o pid,ni,cmd -p 18432
renice
PID

ionice — disk friendly

Class 3 (idle) I/O runs only when the disk is otherwise idle — pair with nice for heavy rsync.

bashbackup
ionice -c3 nice -n 19 rsync -a /data/ /mnt/backup/
ionice -c3
I/O class

nice vs ionice vs cgroups

Nice does not fix I/O saturation; ionice does not fix CPU-bound loops. For containers, also tune cpu.weight / IO limits.

WarningOnly root can set negative nice (higher CPU priority). Abusing nice -n -20 on shared systems can violate fair-use policy.
compare
cgroups

Quick Reference

  • New job: nice -n 19 command
  • Running: renice +n -p PID
  • Disk: ionice -c3 command

Related tutorials

Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.