Score:0

Linux, want to rotate oldest one files when it reaches limit

us flag

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).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.