logrotate does not remove the logs after the configured period

Solution Verified - Updated -

Issue

  • logrotate script not removing log files older than two days.
/var/log/rsyslog-application/*.log
/var/log/rsyslog-application/*.log {
    daily
    rotate 2
    notifempty
    nocreate
    dateext
    compress
    sharedscripts
    postrotate
       /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}
  • Above logrotation configuration should keep only two files and remove all the logfiles.
    But it is not working as expected.

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • logrotate
  • Rsyslog

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content