Back to lessons

Hosting Operations

Summarize Cache File Ages

A cache tree is using many inodes and you need to see file age distribution before deciding on a retention threshold.

Command

find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c

What changed

Nothing changes. The command groups cache files by modification date.

Danger

safe

When to use it

Use before age-based cache cleanup so the cutoff is based on the actual file population.

When not to use it

Do not use file age alone for application-owned caches that have their own invalidation or lock semantics.

Undo or recovery

No undo needed because this is a read-only summary.

Expected output

Counts of cache files grouped by date.

demo script

Disposable terminal steps

  1. find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
  2. find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
    160 2026-06-26
::exit-code::0
$ find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr
    120 /lab/disk-inode-cleanup/var/cache/app/shards/a
     40 /lab/disk-inode-cleanup/var/cache/app/shards/b
::exit-code::0

YouTube Short

Check cache age first.

Before choosing a cache cleanup cutoff, count files by date. It turns a risky guess into a visible threshold.

LinkedIn hook

Cache cleanup is safer when you know whether files are stale or still active.

Question: Do you choose cache cleanup thresholds from file age data or from habit?

experiments

A/B tests to run

Metric: share_rate

A: Choose cache cutoffs from evidence.

B: Count cache files by age first.