logrotate

Automatically rotate, compress, and manage log files.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

logrotate manages log file rotation on a schedule — compressing old logs, deleting logs older than N days, and sending signals to services to reopen log files. Config in /etc/logrotate.conf and /etc/logrotate.d/. Run by cron or systemd timer daily.

Common flags
FlagMeaning
-d --debugDry run — show what would happen without doing it
-f --forceForce rotation even if not due
-v --verboseVerbose output
Examples
logrotate -d /etc/logrotate.d/nginxDry run nginx log rotation config · explain & risk-check →
logrotate -f /etc/logrotate.confForce rotate all logs immediately · explain & risk-check →
logrotate -v /etc/logrotate.d/myappVerbose rotation for debugging · explain & risk-check →
cat /etc/logrotate.d/nginxView nginx logrotate config · explain & risk-check →
Pro tip

Always test new logrotate configs with `-d` (dry run) first. Common mistake: missing `postrotate` signal to the daemon to reopen files — without it, the service keeps writing to the rotated file.

Related
rsyslog journalctl find
Open the full explainer →More in System & Processes

Reference text is hand-written and may be incomplete — check man logrotate for your version. Test destructive commands on a non-production system first.