in Linux commands

iotop : How to save the ouput in log file ?

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.50 out of 5)
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

Written By:

Blog for everything about hosting, website, server and technical support

Add a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.