2

Why would logrotate delete the file instead of rotating it?

Here's the config:

/var/log/httpd/*log {
    size 1G
    missingok
    notifempty
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}
1
  • What did the solution end up being? The accepted answer suggests a few things so some further insight would be helpful!
    – niczak
    Commented Jan 9, 2018 at 14:28

1 Answer 1

6

Your config looks ok, there is likely some default in your /etc/logrotate.conf that is deleting files.

If you have rotate 0 in your config file, old files will be deleted rather than rotated.

It may be that the files are being rotated but you are looking in the wrong place.
Check the logrotate logs with cat /var/lib/logrotate/status to verify that logrotate is running as expected.
And of course, familiarize yourself with logrotate by reading the man page

1
  • logrotate -d should have shown the effective config. Thanks to this post, I know rotate 0 in the /etc/logrotate.conf is the culprit troubling me for long!
    – silencej
    Commented Jul 28, 2020 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.