如何使用logrotate压缩超过1天的文件

时间:2018-03-20 11:53:28

标签: linux logrotate log-rotation

我有一个文件列表,我希望logrotate能够压缩一天。所以我期待 TRACE_03.log,TRACE_07.log ,已被压缩,因为它超过24小时

# 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

现在我的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
}

对于我的Trace.log配置

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

我的配置中缺少什么,它在这里不起作用?

0 个答案:

没有答案