Force or dry-run log rotation with logrotate
Preview what logrotate will do, or rotate logs immediately after big config changes.
01Command
$ sudo logrotate -f /etc/logrotate.conf02What it does
logrotate normally runs from a daily systemd timer or cron job, rotating and compressing logs that exceed their size or age rules. The -d flag does everything except actually touching files, printing which logs would rotate and why — ideal for testing a new /etc/logrotate.d/ rule. -f forces rotation on every log, regardless of schedule.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- logrotate(8) - Linux manual pageEvidence: SYNOPSIS logrotate [--force] [--debug] [--state file] configfile ... with --force forcing rotation even when not due.
- logrotate(8) — Debian bookwormEvidence: Documents -f, --force, -d, --debug (dry run) and -v, --verbose for the log rotation tool.
Last verified: 2026-09-19 · Category: Files & Folders
06Related solutions
ncdu scans a directory tree, then lets you browse sizes, navigate, and delete space hogs with one keypress.
dmesg prints kernel messages with seconds since boot by default; -T converts them to real dates and times.
Log rotation compresses old logs to .gz; zcat, zless, and zgrep let you pipe, page, and search them directly.