in Linux commands

How to save the ouput of iotop in log file ?

4.00
1 Star2 Stars3 Stars4 Stars5 Stars
Ratings: 4.00/5 from 2 users.
Loading...

You can use cron task scheduling to get iotop to run every minute and log any I/O activity it detects.

Open this file for editing:

/etc/cron.d/iotop

And put the following into that file:


# Run iotop and log any detected activity.
* * * * * root iotop -botqqq --iter=3 >> /var/log/iotop

Save the file. That cron.d entry will cause iotop to run every minute, logging any I/O activity it finds to “/var/log/iotop”.

Cron
Cron

It takes three samples when it runs (five seconds apart), doesn’t log headers or summary information, and only logs processes with measured I/O activity.

After a minute take a look in /var/log. If the script ran as expected there should now be an “iostat” log there (though it may be an empty file if it didn’t find any I/O to log).

Tweak the command to your liking. If you want a different number of samples per minute change the “–iter” value. If you want I/O summaries printed when the script runs change “qqq” to “qq”.

Related Posts

Add a Comment

Your email address will not be published. Required fields are marked *