Affected versions: CentOS Stream 10

📖 ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution – Primary Fix
  7. Solution – Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

Symptom & Impact

Old log files pile up because postrotate scripts never reload services.

Environment & Reproduction

logrotate runs but postrotate exits non-zero silently.

logrotate --version
cat /etc/logrotate.d/myapp

Root Cause Analysis

Errors in postrotate are not logged by default.

Quick Triage

Run logrotate manually with verbose mode.

logrotate -dv /etc/logrotate.d/myapp
logrotate -fv /etc/logrotate.d/myapp

Step-by-Step Diagnosis

Capture exit codes from postrotate.

bash -x /etc/logrotate.d/myapp 2>&1 | tail -40
journalctl -u logrotate.service -n 50 --no-pager
Illustrative mockup for centos-stream-10 — logrotate_fail
logrotate postrotate fail — Illustrative mockup — Progressive Robot

Solution – Primary Fix

Fix the postrotate command and add error logging.

Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

sed -i 's|postrotate.*|postrotaten    systemctl reload myapp || logger logrotate-failn    endscript|' /etc/logrotate.d/myapp
Illustrative mockup for centos-stream-10 — logrotate_ok
logrotate clean — Illustrative mockup — Progressive Robot

Solution – Alternative Approaches

Use copytruncate where reload is not feasible.

sed -i 's|missingok|missingokn    copytruncate|' /etc/logrotate.d/myapp

Verification & Acceptance Criteria

Old logs are removed and the service writes to the new file.

ls -ltrh /var/log/myapp | head
lsof -p $(pidof myapp) | grep myapp.log

Rollback Plan

Restore the prior logrotate config.

cp /etc/logrotate.d/myapp.bak /etc/logrotate.d/myapp

Prevention & Hardening

Add an audit check that logrotate runs successfully each night.

journalctl -u logrotate.service --since=yesterday | tail

Disk fills up, log file held open by old process.

Related tutorial: View the step-by-step tutorial for centos-stream-10.

View all centos-stream-10 tutorials on the Tutorials Hub →

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

logrotate docs, copytruncate notes.

Need Expert Help?

If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.