-2

How can I print/capture the top 10 io usage? I'm using the iotop -o | head -n 11 but the output keeps changing. I wanted to capture the first output after running it.

Thank you,

4
  • Top 10 of what? Processes?
    – Turdie
    Commented Dec 5, 2023 at 13:07
  • 1
    Note that IO is measured over a time interval and measuring IO over a longer time interval most likely will see a different pattern of I/O usage and top users than the default short 1 second sampling.
    – HBruijn
    Commented Dec 5, 2023 at 13:20
  • @Turdie top 10 I/O usage for the last 5 mins.
    – IamBayMax
    Commented Dec 10, 2023 at 21:29
  • @HBruijn how can I capture the usage for the last 5 mins? is it possible to save it to text file?
    – IamBayMax
    Commented Dec 10, 2023 at 21:30

2 Answers 2

0

RMaaS

man iotop

-b, --batch 

Turn on non-interactive mode. Useful for logging I/O usage over time.

-n NUM, --iter=NUM

Set the number of iterations before quitting (never quit by default). This is most useful in non-interactive mode.

Thus:

 iotop --batch -n 1  |head
1
  • thanks for sharing. I tried to run it but the output is kinda messy. How can I make the output like the result in interactive mode?
    – IamBayMax
    Commented Dec 5, 2023 at 13:26
0

To execute iotop only once you need to exec the command on this way:

iotop -n 1|head -n 11

To clear a bit of output you can try something like:

iotop -q -n 1|head -n 11
5
  • thanks for sharing. i need an non-interactive command but the result is like the interactive. thanks
    – IamBayMax
    Commented Dec 5, 2023 at 13:27
  • @IamBayMax, add another option to the answer Commented Dec 5, 2023 at 13:46
  • can you share what option i should add?
    – IamBayMax
    Commented Dec 5, 2023 at 20:25
  • @IamBayMax, I edited my answer, did you check it? The option is -q Commented Dec 6, 2023 at 5:38
  • yes but i need a non-interactive command as I will run it remotely.
    – IamBayMax
    Commented Dec 7, 2023 at 21:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .