ionice
Set I/O scheduling priority for a process
TLDR
Run a command with the given scheduling class and priority
Set I/O scheduling class of a running process with a specific [p]id, [P]gid, or [u]id
Run a command with custom I/O scheduling class and priority
Ignore failure to set the requested priority
Run the command even in case it was not possible to set the desired priority (this can happen due to insufficient privileges or an old kernel version)
Print the I/O scheduling class and priority of a running process
SYNOPSIS
ionice [-c class] [-n level] [-t] -p PID...
ionice [-c class] [-n level] [-t] COMMAND [ARG...]
PARAMETERS
-c, --class=class
Set I/O class: 0(none), 1(realtime), 2(best-effort, default), 3(idle); or names realtime, best-effort, idle
-n, --classdata=level
Set priority level 0-7 (0 highest); ignored for idle class
-p, --pid=PID...
Target existing process ID(s)
-t, --ignore
Ignore errors setting target class (e.g., non-root realtime)
-h, --help
Display usage help
-V, --version
Output version information
DESCRIPTION
The ionice command manages the I/O priority and scheduling class of Linux processes, influencing how disk I/O operations are handled by the kernel's I/O scheduler, primarily CFQ (Completely Fair Queuing) or compatible schedulers like BFQ. It allows users to prioritize I/O requests to ensure critical tasks get preferential access to block devices, preventing low-priority jobs from starving high-priority ones.
Processes are assigned to one of three I/O classes:
- Realtime (1): Highest priority; I/O requests serviced first, levels 0-7 (0 best).
- Best-effort (2): Default class; fair sharing with priority levels 0-7 (0 highest).
- Idle (3): Lowest priority; I/O only when idle, no level needed.
Use -p PID to adjust running processes or invoke a command directly for new ones. Without arguments, it displays the current shell process's I/O class and priority. This is useful for batch jobs, backups, or multimedia to avoid I/O contention. Root privileges are typically required for realtime class or modifying other users' processes. Modern kernels extend support beyond CFQ, but effectiveness varies by scheduler and workload.
CAVEATS
Requires CFQ/BFQ-like I/O scheduler; ineffective with noop/deadline. Root needed for realtime class or foreign PIDs. Levels apply per-task; cgroup overrides possible. No effect on non-block I/O.
EXAMPLES
ionice -c 3 dd if=/dev/zero of=bigfile bs=1M
Run dd as idle class.
ionice -c 1 -n 0 -p $(pidof mysqld)
Set realtime I/O priority 0 for MySQL.
QUERY CURRENT
Run ionice without args to print shell's class/priority: e.g., "best-effort: prio 4".
HISTORY
Added in Linux 2.6.13 (2005) by Balbir Singh; part of util-linux since v2.13. Kernel I/O scheduler interface stabilized later.


