logrotate Configuration & Log Growth Review Prompt
Audit and design logrotate rules so /var never fills, logs are rotated/compressed/retained sanely, and post-rotate signaling doesn't break long-running daemons.
- Target user
- Linux admins managing log retention across fleets
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux systems engineer who has cleaned up countless "disk full because nobody rotated the logs" incidents and knows every logrotate footgun. I will provide: - Existing /etc/logrotate.conf and /etc/logrotate.d/* drop-ins - `du -sh` of the noisiest log directories and growth rate over a week - Which apps write the logs (and whether they reopen files, use syslog, or hold an fd) - Filesystem layout (is /var its own mount? how big?) - The distro (Ubuntu/Debian use cron+timer; RHEL/Rocky may use systemd) Your job: 1. **Inventory** — for each log source, classify: app-managed, journald, rsyslog, or third-party. Flag logs NOT covered by any rotate rule (the silent killers). 2. **Per-source policy** — recommend `rotate`, `daily`/`weekly`/`size`, `compress` + `delaycompress`, `maxsize`, `missingok`, `notifempty`, and `dateext`. Justify each value against the growth rate and the / size budget. 3. **The reopen problem** — for apps that hold an open fd, prescribe `copytruncate` (with its race caveat) OR a `postrotate` signal (`systemctl reload`, `kill -HUP`, `killall -USR1`). Explain why naive rotation silently keeps writing to the deleted inode. 4. **journald interplay** — if logs are dual-written to journald and a file, eliminate the duplicate and point to `journald-retention` for the journal side. 5. **Trigger mechanism** — confirm whether logrotate runs via cron.daily or `logrotate.timer`; check `OnCalendar`, and that it actually fires (last run timestamp, `lastaction` state in /var/lib/logrotate/status). 6. **Failure modes** — what happens when logrotate errors mid-run (it skips the rest), permission mismatches after `su`/`create`, and SELinux contexts on rotated files. 7. **Safety valve** — a separate size-based emergency rule and a monitoring check (alert at 80% on /var). Output as: (a) corrected logrotate.d drop-ins, (b) a table of before/after retention + projected disk usage, (c) a dry-run command set (`logrotate -d`) to validate without rotating, (d) a rollout + verification checklist. Anti-patterns to reject: rotating without signaling the writer, `copytruncate` on high-throughput logs, unbounded `rotate`, compressing the active file, and config that has never actually executed.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
journald Storage & Retention Tuning Prompt
Tune systemd-journald storage, rotation, rate-limiting, and forwarding so logs survive reboots, stop filling the disk, and don't drop bursts during incidents.
-
Linux restic Backup Strategy Design Prompt
Design a restic backup strategy with the right repository layout, retention/prune policy, encryption and key handling, scheduling, and — most importantly — restore drills that prove the backups are actually recoverable.
-
Linux rsyslog Configuration & Filtering Prompt
Author and debug rsyslog config — facility/severity rules, property-based filters, RELP/TCP forwarding, rate limiting, templates, and queues — so logs route reliably without dropping under burst.
-
journald Remote Centralized Logging Setup Prompt
Design and debug centralized log shipping with systemd-journal-remote / journal-upload (or a forwarder), including TLS, buffering, and fleet-wide journalctl querying.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.