track disk usage over time in linux

3

I know I can use df to get a summary of disk usage right now.

I can use du to break down into the detail of how the disk is being used.

The problem is I can only see this information for today.

If I wanted to map a trend I would have to write a script that takes the output of those commands and writes it to a file / log. Which I could later analyse. I was wondering if there is any tool or programs that can do this, that are already included in most Linux distros. Do I have to look at a more heavy weight monitoring solution.

nelaaro

Posted 2012-01-11T06:56:05.903

Reputation: 9 321

Answers

4

It depends on your needs. You can use cron to run e.g. the following as a simple solution for your problem:

df > /path/to/some/directory/df-$( date +%Y%m%d-%H%M%S )

Run crontab -e to open your user's crontab file. Add the following new line to it:

0 0 * * * df > /path/to/some/directory/df-$( date +%Y%m%d-%H%M%S )

This will execute df (optionally with arguments) every day at midnight and write its output to a timestamped file.

From these files, you can then assemble the usage information over time.

Daniel Beck

Posted 2012-01-11T06:56:05.903

Reputation: 98 421

Of course, if you want fancy graphics for your manager, that probably won't do... – Daniel Beck – 2012-01-11T08:40:18.030