Back to Blog
How to Track Disk Space Usage Over Time on a Linux Server

How to Track Disk Space Usage Over Time on a Linux Server

   Mariusz Antonik    Server Health    6 min read    2 views

Disk space rarely disappears all at once. On most servers, it fills gradually — a growing log directory here, an expanding database there — until one day the disk is full and something breaks. The frustrating part is that when you’re only checking disk usage reactively, the problem always feels sudden, even though the warning signs were there for weeks.

Tracking disk space usage over time on your Linux server changes that completely. Instead of knowing only what’s used right now, you build a picture of how fast storage is actually growing. That context is what lets you act before there’s a problem — not after.

This guide walks through practical approaches for tracking disk growth trends on Linux, what to measure, and how to turn raw data into something actionable.

Why Point-in-Time Checks Aren’t Enough

Running df -h tells you how much space is used today. That’s useful, but it doesn’t tell you whether today’s 60% usage is stable, slowly creeping up at 2% per month, or accelerating after a recent deployment. Without the trend, the number doesn’t mean much.

Here’s the thing: most disk-related outages on small infrastructure are entirely predictable. The disk didn’t fill overnight. It filled over days or weeks, and nobody noticed because the team was only checking when something felt wrong. A simple growth trend would have shown the trajectory clearly.

Disk usage trends are especially important for:

  • Database servers — MySQL data files and binary logs grow continuously
  • Log-heavy applications — application logs, access logs, and error logs that aren’t rotated aggressively
  • Backup destinations — incremental backups that stack up quietly
  • Upload or media directories — user-generated content with unpredictable growth

How to Capture Disk Usage Over Time

The approach is straightforward: record disk usage at regular intervals and store those readings somewhere you can query or review them later.

Option 1 — Log to a File with Cron

The simplest method requires no extra tools. Add a cron job that appends a timestamped df snapshot to a log file:

0 * * * * df -h >> /var/log/disk_usage_history.log 2>&1

This runs every hour and appends output to a log file. Over time you build a readable history. The downside is that parsing it later takes some work — you’re looking through plain text, not structured data.

A cleaner approach logs just the numbers in CSV format:

0 * * * * df --output=source,size,used,avail,pcent | tail -n +2 | while read line; do echo date_placeholder; done >> /var/log/disk_usage_history.csv

This gives you a structured file you can later import into a spreadsheet or feed into a simple script to identify trends.

Option 2 — Write to a Local SQLite Database

If you want something queryable without standing up a full monitoring stack, SQLite works well. A small Python script can handle both collection and basic analysis. Schedule it via cron, then query it whenever you want to see the trend for a specific mount point. You can pull weekly averages, calculate growth rate per month, or export to CSV for reporting.

Option 3 — Use a Lightweight Monitoring Agent

If you’re already running something like Netdata, Prometheus node_exporter, or collectd, disk metrics are almost certainly being collected. The gap is usually on the visualization and trend analysis side — the data exists, but nobody is looking at week-over-week or month-over-month growth patterns.

Pull that data into a regular review process. Even a simple weekly query against stored metrics gives you the trend information you need without any additional tooling.

What to Actually Measure

Raw disk usage numbers are a start, but more useful metrics for trend analysis include:

  • Used space per filesystem — absolute growth in GB per week or month
  • Percentage used — useful for alerting thresholds, less useful for growth rate
  • Growth rate — how many GB per day or week is each filesystem growing?
  • Projected fill date — at the current growth rate, when does this filesystem hit 90%?

The projected fill date is particularly useful. If your /var partition is at 55% and growing at 4 GB per week, you can calculate exactly when you need to take action — long before it becomes urgent.

A Real-World Example

Consider a small web server running MySQL. The team runs df -h during a weekly check and sees /var/lib/mysql at 62%. Looks fine. But nobody has been tracking growth.

Three weeks later, the server runs out of disk space overnight. MySQL stops writing. The site goes down.

If that team had been recording disk usage history, they would have seen that /var/lib/mysql was growing about 8 GB per week — binary logs were accumulating because the log rotation policy hadn’t been updated after a schema change doubled the write volume. At 62% with 8 GB/week growth on a 200 GB disk, they had maybe five weeks before hitting 90%. The trend would have made that obvious. But this is where it matters: the insight doesn’t come from a louder alert. It comes from looking at the growth pattern over time.

Turning Disk History Into a Regular Health Check

Collecting disk usage history is only half the job. The other half is actually reviewing it. A weekly summary that shows growth per filesystem — even if it’s just a table in a text file or spreadsheet — is enough to catch problems early on most small infrastructure setups.

Look for any filesystem that grew more than expected this week, growth rates that are accelerating compared to the previous period, and filesystems already above 75% that are still growing. You don’t need a complex dashboard to do this. You need consistent data and a habit of reviewing it.

Putting It Together

Tracking disk space usage over time on a Linux server doesn’t require expensive tools or complex infrastructure. A cron job and a log file can get you started today. The key is consistency — recording snapshots regularly enough to show real growth trends, and actually reviewing that data before a problem develops.

When disk growth becomes visible as a trend rather than a sudden surprise, you gain time to plan capacity expansions, adjust log rotation policies, or clean up large directories — on your schedule, not in the middle of an outage. You can explore how systematic disk trend tracking fits into a broader approach with Infrastructure Health Reporting.

About the Author
Mariusz Antonik

Oracle Cloud Infrastructure expert and consultant specializing in database management and automation.

All Tags
#Advanced #Bash #bash cpu monitoring script #bash monitoring #bash scripting #Beginner #Best Practices #block volume backup #Capacity Planning #cloud backup strategy #cpu bottleneck #CPU Monitoring #cpu monitoring linux #cpu monitoring script linux #cpu trends #cpu usage trends linux #create oracle db system in oci #cron cpu monitoring #cron jobs #database monitoring #database performance #detect slow queries mysql #disk capacity planning server #disk forecasting linux #Disk Monitoring #disk usage #disk usage script linux #disk usage trends #Early Detection #easy infrastructure monitoring #free-tier #Guide #health dashboards #Health Reporting #historical server monitoring #infrastructure #infrastructure health #infrastructure health dashboard #infrastructure health reporting #infrastructure monitoring #infrastructure monitoring report #infrastructure trends monitoring #Infrastructure Visibility #lightweight linux monitoring #lightweight monitoring #linux administration #linux cpu monitoring #linux cpu usage #linux disk capacity planning #linux disk usage #Linux monitoring #linux monitoring tools #linux performance #linux performance monitoring #linux server #linux server monitoring #linux servers #linux storage #linux tools #low maintenance monitoring #monitor cpu usage over time linux #monitor linux server health #monitor server trends #monitor small production server #monitoring without complexity #MySQL #mysql health reporting #MySQL monitoring #mysql optimization #MySQL Performance #mysql performance degradation #mysql performance monitoring #mysql performance trends #mysql query performance issues #mysql server monitoring #mysql slow queries #mysql slow query analysis #mysql slow query monitoring #mysql trends #mysql-health #networking #nsg #OCI #oci backup #oci bastion tutorial #oci block volume #oci infrastructure as code #oci networking #oci oracle database private subnet setup #oci oracle database tutorial #oci security #oci setup guide #oci terraform tutorial #oci tutorial for beginners #oci vcn terraform #oci virtual machine db system guide #oracle base database service tutorial #oracle cloud bastion #oracle cloud free tier tutorial #oracle cloud infrastructure step by step #oracle cloud infrastructure tutorial #oracle cloud storage #oracle database on oci setup #oracle-cloud #Performance Degradation #performance monitoring #performance trend monitoring #performance trends #plan disk growth server #practical server monitoring #predict disk usage growth #private instance access #query optimization #Security #security lists #server health #server health reporting #server health weekly report #server monitoring #Server Performance #server trend analysis #server-trends #simple linux monitoring #simple monitoring system #simple ops monitoring #slow queries #slow query reporting mysql #small business infrastructure #small business IT #small business servers #small infrastructure monitoring #small server monitoring #ssh bastion #storage capacity planning linux #storage monitoring #subnets #system health reporting #terraform oci compute #terraform oracle cloud infrastructure #Trend Monitoring #Tutorial #vcn