Search code examples
logginggloballogrotate

Global logrotate.conf not considering logs


Noob here (Ubuntu 20.04). I have multiple logs that currently have logrotate config files included in /etc/logrotate.d. I want all logs to follow global logrotate settings (/etc/logrotate.conf) so I can maintain everything in one place, specifying log-specific directives where needed. One of these logs is /var/log/apt/history.log, which is not included when I run logrotate in debug mode.

  1. I removed the non-global config file - /etc/logrotate.d/apt - that should have taken precedence over the global logrotate.conf file.
  2. I updated /etc/logrotate.conf with the following directives to test whether or not /var/log/apt/history.log was leveraging the global conf file or not:
/var/log/apt/history.log {
rotate 12
hourly
missingok
delaycompress
}
  1. When debugging, the log is not included. After waiting several hours for logrotate to run natively, nothing happens. What am I missing?

Solution

  • Resolved by waiting overnight. My best guess: since the log was already rotated once in the day, despite including directives for hourly rotation and using the --force command when debugging, /var/log/apt/history.log, the logs still weren't considered for rotation.

    From man logrotate:

    Normally, logrotate is run as a daily cron job. It will not modify a log multiple times in one day unless the criterion for that log is based on the log's size and logrotate is being run multiple times each day, or unless the -f or --force option is used.