Search code examples
amazon-ec2logrotateamazon-linux-2

logrotate 3.8.6 on amazon linux 2 does not respect size limit


logrotate.d configuration on an amazon linux 2 for awslogs is the following

/var/log/awslogs.log {
    missingok
    notifempty
    size 100M
    create 0600 root root
    delaycompress
    compress
    rotate 4
    postrotate
        systemctl restart awslogsd
    endscript
}

From time to time, the log has a tendency to quickly go over a GB (well over the size limit 100M) long before the cron.daily logrotate kicks the process. When I run logrotate manually with -vf flag though, it identifies the need to rotate this oversize log and takes action.

I cannot find a clue in messages log on whether or not the daily job errors out while trying to rotate it. I understand that post 3.8.1, this scenario should have been supported but it does not appear so. https://serverfault.com/questions/391538/logrotate-daily-and-size#434645

Any suggestions on how to troubleshoot why the log is not rotating when size hits the limit put in here?


Solution

  • I actually was using the wrong parameter. I should have used maxsize instead of size. This good answer