📖 ~1 min read
Table of contents
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

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

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
Related Errors & Cross-Refs
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.