• Uncategorized

About linux : How-to-use-logrotate-to-compress-files-older-than-1-day

Question Detail

I’ve have a list of files below which I wants logrotate to compress if its a day old. So I’m expecting TRACE_03.log, TRACE_07.log, been compressed as it is more than 24 hrs

# ls -ltr
total 2083312
-rw-r--r--. 1 root root 198176768 Mar 18 01:30 TRACE_03.log
-rw-r-----. 1 root root 198176768 Mar 19 17:19 TRACE_07.log
-rw-r-----. 1 root root 467324318 Mar 19 23:59 TRACE_01.log
-rw-r-----. 1 root root         0 Mar 20 09:27 TRACE_05.log
-rw-r-----. 1 root root         0 Mar 20 09:27 TRACE_06.log
-rw-r-----. 2 root root 634809893 Mar 20 19:45 TRACE.log

Now for my logrotate.conf

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
        minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

For my Trace.log config

/var/log/traces/TRACE_*.log{
    daily
    missingok
    compress
    nodateext
    rotate 1
    maxage 1
}

What am I missing in my configuration that it does not worked here?

Question Answer

No answer for now.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.