How to debug logrotate when it silently fails to rotate logs
logrotate misconfigurations do not produce errors or failed exit codes, meaning disk-full crashes can be the first sign something went wrong. The copytruncate directive, commonly used when processes cannot reopen log files via SIGHUP, creates a race condition on high-throughput servers that can drop or duplicate log entries. A safer alternative is using a postrotate hook to signal the process, such as running nginx -s reload, which allows a clean log file handoff with no data loss. Running logrotate with the -d debug flag before deploying any config change lets administrators preview what the tool would do without actually rotating files. Additional common pitfalls include missing compress directives on high-volume logs and processes holding open file descriptors on already-rotated files, the latter of which can be identified using lsof +L1.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in