Sometimes you want a background task to be less aggressive, or a critical job to get more CPU. Linux gives you several ways to influence the scheduler — without needing to be the scheduler yourself.
The Nice Value
What does the nice value actually do?
It's a scheduling hint to the CFS. Nice values range from -20 (highest priority, "I'm mean, give me CPU") to +19 (lowest priority, "I'm nice, let others go first"). Default is 0. Think of it as how "nice" a process is to its neighbors.
# Start a command with specific nice value
nice -n 10 ./heavy-backup.sh # lower priority
nice -n -5 ./important-job.sh # higher priority (needs root for negative)
# Change nice value of running process
renice +15 -p 1234 # make process 1234 very low priority
renice -5 -p 1234 # increase priority (needs root)
renice +10 -u bob # lower priority for all of bob's processes
# View nice values
ps -eo pid,ni,comm | head -20
top # NI column shows nice value
Rule: Any user can increase their nice value (lower priority). Only root can decrease it (raise priority).
Priority vs Nice
In top's PR column, you see the actual scheduling priority. For normal processes: Priority = 20 + nice. So nice=0 → priority=20, nice=-20 → priority=0, nice=+19 → priority=39.
Real-time processes (SCHED_FIFO, SCHED_RR) have priorities from 1-99 in a separate range — always higher than any SCHED_NORMAL process. They show as negative PR values in top (PR=-50 or similar).
Real-Time Priority — chrt
When do you need real-time scheduling?
For latency-sensitive tasks where you need guaranteed CPU access within microseconds: audio processing (JACK), industrial control systems, high-frequency trading, robotics. RT processes preempt ALL normal processes.
# Run with SCHED_FIFO priority 50
chrt -f 50 my-realtime-app
# Run with SCHED_RR priority 30
chrt -r 30 my-app
# Check/change policy of running process
chrt -p 1234 # show current
chrt -f -p 50 1234 # change to FIFO priority 50
# DANGER: a SCHED_FIFO process that loops forever
# will starve all other processes. Use carefully.
I/O Priority — ionice
Like nice but for disk I/O. Three I/O scheduling classes:
Class
Value
Behavior
Real-time
1
Always gets I/O first. Use carefully.
Best-effort
2
Default. Priority 0-7 (lower = higher priority)
Idle
3
Only gets I/O when no other process wants it
# Run backup with idle I/O (won't impact other apps)
ionice -c 3 rsync -av /home /backup
# Combine with nice for truly background task
nice -n 19 ionice -c 3 find / -name "*.log" -mtime +30 -delete
# Check I/O priority of a process
ionice -p 1234
Frequently Asked Questions
What will I learn here?
This page covers the core concepts and techniques you need to understand the topic and progress confidently to the next lesson.
How should I use this page?
Start with the overview, then follow the section links to deepen your understanding. Use the table of contents on the right to jump to specific sections.
What should I read next?
Use the navigation below to continue to the next lesson or explore related topics.