βš™οΈ Linux/Unix: Process & Job Control
Estimated reading: 3 minutes 277 views

Linux/Unix: Process Scheduling – nice, renice, chrt Explained with Examples

Introduction – Why Learn Scheduling Commands in Linux?

Linux is a multi-tasking operating system, where multiple processes run concurrently. Sometimes, you need to prioritize or deprioritize processes for optimal performance. That’s where nice, renice, and chrt come inβ€”they control the CPU scheduling priority of processes.

In this guide, you’ll learn:

  • How Linux handles process priorities
  • Difference between nice values and real-time priorities
  • How to schedule tasks using nice, modify them using renice, and apply real-time policies using chrt

Understanding Scheduling in Linux

  • Nice value: Determines priority for non-real-time processes (range: -20 [highest] to 19 [lowest], default is 0)
  • Real-time priority: Managed by chrt, works with FIFO and RR (Round Robin) policies
ToolAffectsRange / ModesPrivilege Required
niceNew processes-20 to 19 (default 0)Yes (for -ve)
reniceRunning processes-20 to 19Yes (for others)
chrtReal-time tasksFIFO, RR, OtherYes (root needed)

nice – Launch Process with Custom Priority

Syntax:

nice -n [value] command

Description:

Runs a command with a custom nice value. Higher value = lower priority.

Example 1: Run with lower priority

nice -n 10 long_running_task.sh

Output: (No output unless the script prints something)

Example 2: Run with higher priority (requires root)

sudo nice -n -5 myscript.sh

renice – Change Priority of a Running Process

Syntax:

renice [nice_value] -p [PID]

Description:

Changes the nice value of an already running process.

Example:

renice 5 -p 1234

Output:

1234 (process ID) old priority 0, new priority 5

Change priority for all user’s processes:

renice 10 -u john

chrt – Set or View Real-Time Scheduling

Syntax:

chrt [options] priority command

Description:

Assigns a real-time scheduling policy (FIFO, RR, OTHER) and priority to a process.

Example 1: Run with FIFO policy

sudo chrt -f 50 ./critical_task

Output: (Runs in real-time FIFO mode at priority 50)

Example 2: Check current scheduling policy

chrt -p 1234

Output:

pid 1234's current scheduling policy: SCHED_OTHER
pid 1234's current scheduling priority: 0

Scheduling Use Cases

TaskUse This ToolExample
Lower priority for backupnicenice -n 15 rsync ...
Raise priority for compilerrenicerenice -5 -p 3231
Real-time video renderingchrtchrt -f 80 ./render
Balance multi-user CPU loadrenicerenice 10 -u username

Summary – Recap & Next Steps

Linux lets you tune process scheduling to manage system performance and responsiveness. With nice, renice, and chrt, you can control which tasks get CPU time and whenβ€”ensuring critical processes run smoothly.

Key Takeaways:

  • nice starts a command with a custom priority.
  • renice changes priority of already running processes.
  • chrt assigns real-time priorities using FIFO/RR policies.
  • Lower nice values = higher priority; chrt offers stricter scheduling.

FAQs

What’s the default nice value in Linux?
It’s 0.

What’s the lowest and highest nice value possible?
Highest priority = -20, Lowest priority = 19.

Can any user lower the nice value (raise priority)?
No, only root can assign negative nice values.

What is the difference between nice and chrt?
nice changes user-space CPU priority, while chrt controls real-time scheduling policies.

How do I check the priority and scheduling policy of a process?
Use:

chrt -p <PID>

Share Now :
Share

πŸ”΅ Linux/Unix: Scheduling (nice, renice, chrt)

Or Copy Link

CONTENTS
Scroll to Top