Error Codes Wiki

Logrotate Errors — Log Rotation Configuration and Permission Failures on Linux

Informationalsystem

Overview

Fix Linux logrotate errors including configuration syntax failures, permission denied during rotation, and logs not being rotated as expected.

Key Details

  • Logrotate manages log file rotation, compression, and deletion based on configuration rules
  • Configuration files: /etc/logrotate.conf (global) and /etc/logrotate.d/ (per-application)
  • Logrotate runs daily via systemd timer or cron — check scheduling if logs are not rotating
  • The 'copytruncate' directive is needed for applications that hold log files open (cannot be renamed)
  • SELinux contexts on log files can prevent logrotate from operating correctly

Common Causes

  • Configuration syntax error preventing logrotate from processing rules
  • Logrotate cron job or systemd timer not running
  • Permission issues — logrotate running as root but log files owned by application user
  • Application holding log file open — rename-based rotation creates a new file the app does not write to

Steps

  1. 1Test configuration: 'logrotate -d /etc/logrotate.conf' to debug without actually rotating
  2. 2Force rotation: 'logrotate -f /etc/logrotate.d/myapp' to test rotation immediately
  3. 3Check the timer: 'systemctl status logrotate.timer' or 'cat /etc/cron.daily/logrotate'
  4. 4Use 'copytruncate' for apps that hold files open: it copies the log and truncates the original in place
  5. 5Fix SELinux: 'restorecon -rv /var/log/myapp/' to reset log file security contexts

Tags

logrotatelog-rotationlog-managementcronsysadmin

More in System

Frequently Asked Questions

Use 'create' (default) when the application can reopen log files after rotation (e.g., via SIGHUP). Use 'copytruncate' when the application keeps the log file open and cannot be signaled to reopen.