Back to lessons

Hosting Operations

Preview Old Temp Files Before Deleting

A temporary upload directory may contain stale files, but you need evidence before removing anything.

Command

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

What changed

Nothing changes. The command prints only candidate files older than the threshold.

Danger

safe

When to use it

Use before manual cleanup of upload, export, cache, or temp paths where age matters.

When not to use it

Do not pipe this directly to rm until owners, retention rules, and open-file state are understood.

Undo or recovery

No undo needed because the command only prints candidates.

Expected output

Old candidate files with modification date, byte size, and path.

demo script

Disposable terminal steps

  1. find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -printf '%TY-%Tm-%Td %10s %p\n' | sort
  2. find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' | sort

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -printf '%TY-%Tm-%Td %10s %p\n' | sort
2026-06-01   78643200 /lab/disk-inode-cleanup/var/tmp/uploads/old-export.tar
2026-06-25   23068672 /lab/disk-inode-cleanup/var/tmp/uploads/recent-export.tar
::exit-code::0
$ find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' | sort
2026-06-01   78643200 /lab/disk-inode-cleanup/var/tmp/uploads/old-export.tar
::exit-code::0

YouTube Short

Print cleanup candidates first.

Use find to print old temp files before deletion enters the conversation. Age and size make the review concrete.

LinkedIn hook

The safe version of cleanup is a candidate list first.

Question: What proof do you require before deleting temp files on a production host?

experiments

A/B tests to run

Metric: share_rate

A: Candidate list first.

B: Preview old temp files before rm.