# How to use chrt command

**URL:** <https://linux-tips.com/t/how-to-use-chrt-command/268>\
**Category:** Shell\
**Created:** [August 23, 2015, 4:04pm UTC](https://linux-tips.com/t/how-to-use-chrt-command/268 "2015-08-23T16:04:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![huseynteknsln](https://linux-tips.com/user_avatar/linux-tips.com/huseynteknsln/32/38_2.png) [@huseynteknsln](https://linux-tips.com/u/huseynteknsln)\
**Post date:** [August 23, 2015, 4:04pm UTC](https://linux-tips.com/t/how-to-use-chrt-command/268/1 "2015-08-23T16:04:35Z")

</div>

You can use `chrt` command to set or retrieve the real time scheduling attributes-scheduling priority of an existing `pid`. You can also run command with the given attributes.

First of all you need to know,

1. **SCHED\_FIFO** : First in, first out, real time processes.
2. **SCHED\_RR** : Round robin real time processes.
3. **SCHED\_OTHER** : Normal time/schedule sharing.
4. **SCHED\_BATCH** : Almost the same as the SCHED\_OTHER, but the process is considered always the most cpu consuming.

To get / retrieve the real-time attributes of an existing task / PID, enter:

```sh
$ chrt -p pid

```

For example,

```sh
$ pidof firefox
17588
$ chrt -p 17588
pid 17588's current scheduling policy: SCHED_OTHER
pid 17588's current scheduling priority: 0

```

- How do I use chrt command to set real time attributes of a Linux process?

```sh
$ sudo chrt -p prio pid

```

For example,

```sh
$ sudo chrt -p 20 17588

```

- To set scheduling policy to **SCHED\_BATCH** (`-b` or `--batch`), for example:

```sh
$ chrt -b -p 0 17588

```

- To set scheduling policy to **SCHED\_FIFO** (`-f` or `--fifo`), for example:

```sh
$ sudo chrt -f -p 20 17588

```

> Note: Range of number is [1-99]=\>20.

- To set policy scheduling policy to **SCHED\_OTHER** (`-o` or `--other`), for example:

```sh
$ chrt -o -p 0 17588

```

- To set scheduling policy to **SCHED\_RR** (`-r` or `--rr`), for example:

```sh
$ sudo chrt -r -p 50 17588

```

> **Note** : Range of number is [1-99]=\>50.

> **Note** : Setting a realtime scheduling policy (SCHED\_RR or SCHED\_FIFO) requires root permissions, so you either have to be root or run it with sudo.

- Before setting new scheduling policy, you need to find out min and max valid priorities for each scheduling algorithm, show min and max valid priorities. For example,

```sh
$ chrt -m
SCHED_OTHER min/max priority	: 0/0
SCHED_FIFO min/max priority	: 1/99
SCHED_RR min/max priority	: 1/99
SCHED_BATCH min/max priority	: 0/0
SCHED_IDLE min/max priority	: 0/0

```

_See man page:_ _[man chrt (1): manipulate the real-time attributes of a process](http://manpages.org/chrt)_
