
chrt Command in Linux
The chrt is a command-line utility in Linux that stands for "change real-time attributes''. As the name itself suggests, this command handles the real-time scheduling attributes of a process. Using the chrt command, you can check and adjust the scheduler policies and priorities.
This command lets us execute a new process with specific properties or change the properties of an already executing process. In this article, well discuss several use cases of the chrt command in Linux using practical demonstration.
Table of Contents
Here is a comprehensive guide to the options available with the chrt command −
- chrt Command Basic Syntax in Linux
- chrt Command Options in Linux
- chrt Command Manual Page
- How to Install chrt in Linux?
- How to Check chrt Version?
- How to Check the Current Scheduling Policy of a Process?
- How to Change the Current Scheduling Policy of a Process to FIFO?
- How to Change the Current Scheduling Policy of a Process to SCHED_BATCH?
- How to Change the Current Scheduling Policy of a Process to Default Policy?
- How to Check the Valid Range of Priorities?
- How to Access the Help Page of chrt Command in Linux?
chrt Command in Linux
The chrt command in Linux can be used to set or retrieve the real-time scheduling attributes of a process based on its PID or to execute a command with the given real-time scheduling attributes.
chrt Command Basic Syntax in Linux
To use this command in Linux, simply use the following syntax −
#For executing a new command with specific real-time scheduling attributes chrt [options] priority command [argument ...] #For changing the scheduling attributes of an existing process based on its PID chrt [options] -p [priority] PID
chrt Command Options in Linux
The chrt command in Linux supports several options that enable users to achieve different functionalities related to setting and managing real-time scheduling attributes of processes −
Option | Description |
---|---|
-a, --all-tasks | It operates on all tasks (threads) associated with a given process ID (pid). |
-b, --batch | It sets the policy to SCHED_BATCH scheduling. |
-d, --deadline | It sets the scheduling policy to SCHED_DEADLINE. |
-f, --fifo | It sets the scheduling policy to SCHED_FIFO. |
-h, --help | It retrieves the help page of the chrt command. |
-i, --idle | This option is applied to use idle scheduling. |
-m, --max | It retrieves the minimum and maximum valid priorities and then exits. |
-o, --other | It sets the scheduling policy to SCHED_OTHER. |
-p, --pid | It operates on an already existing process with the specified PID. |
-r, --rr | It is used to specify the round-robin scheduling, i.e., SCHED_RR. |
-V, --version | It retrieves the version information of the chrt command. |
-v, --verbose | It retrieves the status details. |
chrt Command Manual Page
To learn more about the chrt command, its usage in Linux, and its options, explore its manual page by executing the following command −
man chrt

How to Install chrt in Linux?
The chrt command belongs to the util-linux package and comes preinstalled on most Linux distributions. However, if this utility is not installed on your system for some reason, you can install it using a package manager, as shown below −
#For installing chrt on Debian-based systems sudo apt install util-linux #For installing chrt on RedHat, CentOS-based systems sudo yum install util-linux #For installing chrt on Arch Linux sudo pacman -S util-linux #For installing chrt on Fedora sudo dnf install util-linux
How to Check chrt Version?
To check which version of the chrt command you are using, simply execute the following command
chrt -V

How to Check the Current Scheduling Policy of a Process?
Suppose Firefox is running, we can find its ID (PID) using the below-given command −
pidof -s firefox

Once you get the PID of the desired process, you can execute the chrt command to see its scheduling policy as follows −
chrt -p 4746
The output shows that the current scheduling policy of Firefox is SCHED_OTHER and the current scheduling priority is 0 −

How to Change the Current Scheduling Policy of a Process to FIFO?
You can use the chrt command with the -f option to set the current scheduling policy of a process to first in first out. For instance, in the previous example, the scheduling policy of the pid 4746 was SCHED_OTHER and the scheduling priority was 0. Lets change the scheduling policy to SCHED_FIFO and scheduling priority to 2 using the following command −
sudo chrt -f -p 2 4746
The cursor moves to the next line, indicating that the command executes successfully −

Lets confirm the changed scheduling policy and priority by using the following command −
chrt -p 4746

How to Change the Current Scheduling Policy of a Process to SCHED_BATCH?
To change the current scheduling policy to SCHED_BATCH, simply run the chrt command with the -b option as follows −
sudo chrt -b -p 0 4746

Lets verify the changed scheduling policy of the firefox using the following command −
chrt -p 4746

How to Change the Current Scheduling Policy of a Process to Default Policy?
The SCHED_OTHER is the default scheduling policy of a process in Linux. You can change the current scheduling policy of a process to the default scheduling policy by running the chrt command with the -o option, as follows −
#For Setting the Default Scheduling Policy sudo chrt -o -p 0 4647 #For Verifying the Changed Scheduling Policy chrt -p 4746

How to Check the Valid Range of Priorities?
You can use the -m option with the chrt command to check the minimum and maximum priorities, as shown in the following screenshot −
chrt -m

How to Access the Help Page of chrt Command in Linux?
For a profound understanding of the chrt command, you can access its help page. For this purpose, write chrt followed by -h and hit the ENTER key −
chrt -h

Thats all about using the chrt command in Linux.
Conclusion
The chrt command is a handy command in Linux that is used to manage the real-time scheduling attributes of a process. It enables users to change or modify the scheduling policies and priorities of a process. It can execute new processes with specific real-time scheduling attributes or adjust the existing ones. Overall, it enhances the system's performance by efficient task management.
Using the chrt command, users can optimize process scheduling for different applications and use the system resources efficiently. This tutorial covered the basic syntax, various options, and practical examples of the chrt command.