LinuxCommandLibrary

chrt

Set real-time scheduling attributes of processes

TLDR

Display attributes of a process

$ chrt [[-p|--pid]] [PID]
copy

Display attributes of all threads of a process
$ chrt [[-a|--all-tasks]] [[-p|--pid]] [PID]
copy

Display the min/max priority values that can be used with chrt
$ chrt [[-m|--max]]
copy

Set the scheduling priority of a process
$ chrt [[-p|--pid]] [priority] [PID]
copy

Set the scheduling policy of a process
$ chrt --[deadline|idle|batch|rr|fifo|other] [[-p|--pid]] [priority] [PID]
copy

SYNOPSIS

chrt [options] [priority] command [arg...]
chrt [options] -p [priority] pid

PARAMETERS

-b, --batch
    Set policy to SCHED_BATCH.

-d, --deadline period,runtime,deadline
    Set SCHED_DEADLINE (microseconds).

-f, --fifo
    Set policy to SCHED_FIFO (default if unspecified).

-i, --idle
    Set policy to SCHED_IDLE.

-m, --max [min,max]
    Display/set max/min real-time priority range.

-o, --other
    Set policy to SCHED_OTHER.

-p, --pid pid
    Operate on existing process/thread PID.

-r, --rr
    Set policy to SCHED_RR.

-R, --reset-on-fork
    Reset attributes on fork (child inherits).

--sched-policy policy
    Set policy by name (fifo,rr,other,etc.).

-h, --help
    Display help.

-V, --version
    Show version.

DESCRIPTION

chrt is a Linux utility from the util-linux package used to view or set the real-time CPU scheduling attributes of processes. It allows specification of scheduling policies like SCHED_FIFO, SCHED_RR, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, and SCHED_DEADLINE, along with their associated priorities or parameters. This command is essential for real-time applications requiring low-latency or guaranteed CPU execution, such as multimedia processing, embedded systems, or simulations. It can launch new processes with custom attributes or modify running ones via PID. For example, real-time policies (SCHED_FIFO, SCHED_RR) preempt normal tasks based on priority (1-99), enabling precise control. However, misuse can lead to system starvation. Privileges are required: root or CAP_SYS_NICE for most changes. The -m option reveals user-accessible priority ranges, aiding safe configuration. chrt integrates with tools like taskset for full affinity and scheduling control, supporting PREEMPT_RT patches for enhanced determinism.

CAVEATS

Requires root or CAP_SYS_NICE for real-time policies.
High-priority RT tasks can starve the system; test thoroughly.
SCHED_DEADLINE needs kernel 3.14+; params in microseconds.
Not all policies supported on every kernel/CFS scheduler.

EXAMPLES

Launch FIFO RT task:
chrt -f 99 ./my_app

Modify running process:
chrt -r -p 50 1234

DEADLINE example (1ms period):
chrt -d 1000000,100000,500000 ./app

PRIORITY RANGE

Use chrt -m to check: typically 0-99 for RT, but limited per-user (e.g., 0-50).
Set with chrt -m 0,99 (requires privileges).

HISTORY

Introduced in util-linux 2.12 (2004). Added SCHED_DEADLINE in util-linux 2.26 (2014) with Linux 3.14 kernel support. Continuously updated for new schedulers like EEVDF.

SEE ALSO

taskset(1), nice(1), renice(1), ionice(1), sched_setscheduler(2)

Copied to clipboard