0

We have one Linux RHEL Machine where different log files are generating everyday with current date time under "/var/log/audit/" location.

File name are in below format:

audit_2021-11-24.trace
audit_2021-11-25.trace
audit_2021-11-26.trace
audit_2021-11-27.trace
audit_2021-11-28.trace
audit_2021-11-29.trace

I want to rotate the oldest file and delete that file once file count reach 5. For this I configured the below under "/etc/logrotate.d/audit" file

/var/log/audit/audit_*-*-*.trace {
    copytruncate
    dateext
    dateformat -%Y-%m-%d
    rotate 5
    ifempty
    missingok
    compress
}

In CRON Job I configured the below to run in every minute.

* * * * * /usr/sbin/logrotate -f /etc/logrotate.d/audit

But it's not working, this is rotating every file and not deleting the old file (which file are rotated).

user3441151
  • 119
  • 1
  • 2

0 Answers0