chrt Command
Advanced Process Management man(1)Set or get real-time scheduling attributes
📅 Updated: Mar 16, 2026
SYNTAX
chrt [OPTIONS] [POLICY] PRIORITY COMMAND [ARGS]\nchrt [OPTIONS] -p [PRIORITY] PID
What Does chrt Do?
The chrt command sets and retrieves the real-time scheduling policy and priority of processes. Linux supports several CPU scheduling policies: SCHED_OTHER (default, time-sharing), SCHED_FIFO (real-time, first-in-first-out), SCHED_RR (real-time, round-robin), SCHED_BATCH (batch processing), SCHED_IDLE (very low priority), and SCHED_DEADLINE (deadline-based scheduling).
Real-time scheduling policies (FIFO and RR) guarantee that processes run with minimal latency — they will always preempt normal processes. This is critical for audio/video processing, industrial control systems, financial trading applications, and any workload requiring deterministic timing.
chrt is used by system administrators and developers to optimize process scheduling for specific workloads. For example, setting a database process to SCHED_RR ensures it gets CPU time even when the system is under heavy load, reducing query latency spikes.
Real-time scheduling policies (FIFO and RR) guarantee that processes run with minimal latency — they will always preempt normal processes. This is critical for audio/video processing, industrial control systems, financial trading applications, and any workload requiring deterministic timing.
chrt is used by system administrators and developers to optimize process scheduling for specific workloads. For example, setting a database process to SCHED_RR ensures it gets CPU time even when the system is under heavy load, reducing query latency spikes.
Options & Flags
| Option | Description | Example |
|---|---|---|
| -p PID | Get or set scheduling of running process | chrt -p 1234 |
| -f | Set SCHED_FIFO policy (real-time) | sudo chrt -f 50 ./myapp |
| -r | Set SCHED_RR policy (real-time, round-robin) | sudo chrt -r 50 ./myapp |
| -o | Set SCHED_OTHER policy (normal/default) | sudo chrt -o 0 -p 1234 |
| -b | Set SCHED_BATCH policy (batch processing) | chrt -b 0 ./batch-job |
| -i | Set SCHED_IDLE policy (lowest priority) | chrt -i 0 ./background-task |
| -d | Set SCHED_DEADLINE policy | sudo chrt -d --sched-runtime 5000000 --sched-period 10000000 0 ./realtime-app |
| -m | Show minimum and maximum priority for each policy | chrt -m |
| -v | Verbose output | chrt -v -p 1234 |
Practical Examples
#1 Check process scheduling
Show the current scheduling policy and priority of a running process.
$ chrt -p $(pgrep -f postgres)
Output:
pid 1234's current scheduling policy: SCHED_OTHER
pid 1234's current scheduling priority: 0
#2 Run with real-time priority
Start process with FIFO real-time priority 50 (range 1-99). Higher priority = runs first.
$ sudo chrt -f 50 ./audio-processor#3 Set running process to real-time
Change a running process to SCHED_RR with priority 30. No restart needed.
$ sudo chrt -r -p 30 $(pgrep -f myapp)#4 Run batch job at lowest priority
Run compilation as batch job. Gets CPU time only when no interactive processes need it.
$ chrt -b 0 make -j$(nproc)#5 Background task with SCHED_IDLE
Run at absolutely lowest priority. Only gets CPU time when the system is completely idle.
$ chrt -i 0 ./backup-script.sh#6 Show priority ranges
Display minimum and maximum valid priorities for each scheduling policy.
$ chrt -m
Output:
SCHED_OTHER min/max priority\t: 0/0\nSCHED_FIFO min/max priority\t: 1/99\nSCHED_RR min/max priority\t: 1/99
Tips & Best Practices
Real-time can hang system: A SCHED_FIFO process with high priority that never yields CPU can make the system unresponsive. Always test with lower priorities first. Use SCHED_RR for time-sliced real-time.
Priority 99 is reserved for kernel: Avoid priority 99 — it is used by critical kernel threads (watchdog, migration). Use 1-98 for user processes. Priority 50 is a good starting point.
Requires root for real-time: Setting SCHED_FIFO or SCHED_RR requires root (or CAP_SYS_NICE capability). SCHED_BATCH and SCHED_IDLE can be set by regular users for their own processes.
Use with taskset for CPU pinning: Combine chrt (scheduling) with taskset (CPU affinity) for maximum control: sudo chrt -f 50 taskset -c 0-3 ./myapp
Frequently Asked Questions
What is real-time scheduling in Linux?
Real-time policies (SCHED_FIFO, SCHED_RR) guarantee that a process runs immediately when it needs CPU, preempting normal processes. Used for audio, video, trading, and industrial control.
What is the difference between SCHED_FIFO and SCHED_RR?
SCHED_FIFO runs until it yields or is preempted by higher priority. SCHED_RR adds time-slicing — processes at the same priority take turns. SCHED_RR is generally safer.
Can regular users set real-time priority?
Not by default. Requires root or CAP_SYS_NICE. For specific users, add to /etc/security/limits.conf: username - rtprio 50
How do I make a database run with higher priority?
sudo chrt -r -p 30 $(pgrep -f postgres). Or add to systemd unit: [Service] CPUSchedulingPolicy=rr CPUSchedulingPriority=30
Related Commands
More Process Management Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →