ionice Command in Linux with Examples

CFQ I/O disk elevator incorporates a tool called ionice which encourages the director to dole out needs on a process cycle level to accelerate or to confine the disk subsystem use of a particular cycle. For instance in the event that you need to run a rsync order or content to reinforce your documents either locally or distantly use ionice alone with the rsync language structure to accelerate or confine the rsync cycle. 

Note: ionice is stuffed with util-Linux rpm.

Uses of ionice command in Linux:

  • IDLE: A cycle with the allotted I/O need inactive may be conceded admittance to the disk subsystems if no different cycles with a need for best-exertion or higher solicitation admittance to information. Extremely helpful to run assignments suck as updatedb.
  • BEST-EFFORT: As a default, all cycles that don’t demand a particular I/O need are appointed to this class. Cycles will acquire 8 degrees of the need of their particular CPU decent level to the I/O needs a class.
  • Constant: The most noteworthy accessible I/O need is contiguous implying that the individual cycle will consistently be given need admittance to the disk subsystem. The continuous need setting can likewise acknowledge 8 need levels.

Syntax:

ionice -c scheduling_class -n priority_nice_value command

The ionice device acknowledges the accompanying alternatives:



Tag Description
-c, –class class Determine the name or number of the scheduling class to utilize; 0 for none, 1 for real-time, 2 for best-exertion, 3 for inactive. 
-n, –classdata level Determine the scheduling of class information. This possibly has an impact if the class acknowledges a contention. For constant and best-exertion, 0-7 are legitimate information (need levels), and 0 speaks to the most noteworthy need level. 
-p, –pid PID… Indicate the cycle IDs of running cycles for which to get or set the scheduling boundaries. 
-P, –pgid PGID… Indicate the cycle bunch IDs of running cycles for which to get or set the scheduling boundaries. 
-t, –ignore Overlook the inability to set the mentioned need. On the off chance that an order was determined, run it even in the event that it was unrealistic to set the ideal scheduling need, which can occur because of deficient benefits or an old piece form. 
 -h, –help Show help text and exit. 
-u, –uid UID… Indicate the client IDs of running cycles for which to get or set the scheduling boundaries. 
-V, –version Show variant data and exit.

Working with ionice command

1. To set a process, say having PID as 1 to be an idle I/O process.

sudo ionice -c 3 -p 1

set a process with pid ionjice

Here, the “sudo” prefix is used as without it, the operation would not be permitted due to privileges.

2. To run ‘bash’ or any other program as a best-effort program.

ionice -c 2 bash

best efforts program

Here, the bash program would be executed with the scheduling class to be as best-exertion.

3. To run a program with scheduling class, and the priority level.

sudo ionice -c 1 -n 0 bash

scheduling class and priority level



After, the execution of the above command, the user will be logged in as the superuser. Here, the “0” specifies the highest priority.

4. To print the class and priority of the processes have the PID’s like 1 and 2.

ionice -p 1 2

Here, the priorities of the processes with PID 1 and 2 are both idle.

5. To get the IDs of the running processes.

sudo ionice -u 1

Here, the above command will show an error as the process with PID as 1 is listed as an idle process.

6. To get the help text related to the command.

ionice -h

7. To show the ionice’s version and the metadata.

ionice -V

8. To overlook the inability related to the process.

sudo ionice -t 

After the execution of the above command, the failures will be ignored.

Note; Linux supports I/O scheduling priorities and classes since 2.6.13 with the CFQ I/O scheduler.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.