Back to lessons

Hosting Operations

Review Log Files Before Cleanup

Log files are suspected during disk pressure and you need a compact review list before changing retention or truncating anything.

Command

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

What changed

Nothing changes. The command prints log file sizes, dates, and paths for review.

Danger

safe

When to use it

Use before truncating, compressing, rotating, or moving logs during disk incidents.

When not to use it

Do not treat log cleanup as a substitute for fixing missing rotation or runaway logging.

Undo or recovery

No undo needed because the command is read-only.

Expected output

A size-sorted list of log files with modification dates and paths.

demo script

Disposable terminal steps

  1. find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr
  2. find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%s %p\n' | awk '{total += $1} END {printf "log_total_mb=%.1f\n", total/1024/1024}'

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr
  44040192 2026-06-26 /lab/disk-inode-cleanup/var/log/nginx/access.log
  18874368 2026-06-26 /lab/disk-inode-cleanup/var/log/nginx/error.log.1
::exit-code::0
$ find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%s %p\n' | awk '{total += $1} END {printf "log_total_mb=%.1f\n", total/1024/1024}'
log_total_mb=60.0
::exit-code::0

YouTube Short

Review logs before cleanup.

Do not blindly truncate logs during a disk alert. Print size, age, and path first so the cleanup decision is visible.

LinkedIn hook

Before truncating logs, prove which log files are large and how old they are.

Question: Do you check log size and age before truncating during disk incidents?

experiments

A/B tests to run

Metric: completion_rate

A: Do not blindly truncate logs.

B: Review log size and age first.