Back to lessons

Hosting Operations

Rank Old Cleanup Candidates by Size

You have old files in a cleanup path and need to review the largest candidates first without deleting anything.

Command

find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head

What changed

Nothing changes. The command prints old files with byte sizes and sorts the candidates largest first.

Danger

safe

When to use it

Use when cleanup pressure is urgent and you need to focus review on candidates that would actually reclaim space.

When not to use it

Do not delete the largest old file just because it is large; confirm ownership, retention, and whether a process still needs it.

Undo or recovery

No undo needed because this command only prints candidate files.

Expected output

A largest-first list of old files with byte counts, dates, and paths.

demo script

Disposable terminal steps

  1. find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
  2. find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr | awk '{printf "%.1f MB %s %s\n", $1/1024/1024, $2, $3}'

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
78643200 2026-06-01 /lab/disk-inode-cleanup/var/tmp/uploads/old-export.tar
::exit-code::0
$ find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr | awk '{printf "%.1f MB %s %s\n", $1/1024/1024, $2, $3}'
75.0 MB 2026-06-01 /lab/disk-inode-cleanup/var/tmp/uploads/old-export.tar
::exit-code::0

YouTube Short

Rank old files by size.

If cleanup needs space back quickly, sort old candidates by bytes first. Review the big wins before touching anything.

LinkedIn hook

The oldest file is not always the file that buys back meaningful space.

Question: When disk cleanup is urgent, do you review oldest files first or largest old files first?

experiments

A/B tests to run

Metric: save_rate

A: Old is not the same as useful to delete.

B: Rank old cleanup candidates by size.