- 论坛徽章:
- 0
|
各位好,我用logrotate做Iptable日志轮询的时候出了点问题,不甚明白,请求大家帮助!
我希望每日logrotate我的日志文件/tmp/log/iptables,保留60天的记录,下面是我的logrotate配置
-------------------------------------------------
[root@S1~]# more /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
daily
# keep 4 weeks worth of backlogs
rotate 60
# create new (empty) log files after rotating old ones
create
# 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 -- we'll rotate them here
/var/log/wtmp {
monthly
minsize 1M
create 0664 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
[root@S1~]# more /etc/logrotate.d/syslog
/tmp/log/iptables {
daily
rotate 60
missingok
maxage 60
nocompress
create
prerotate
/usr/bin/chattr -a /tmp/log/iptables
endscript
postrotate
/usr/bin/chattr +a /tmp/log/iptables
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
-------------------------------------
现在的问题是,日志在轮询到第10天的时候就会把最早一天的日志文件删除掉,最终只能保留10天的日志。请看下面的ls结果,最新一天的日志文件是
iptables.1,而iptables.12则是最早一天的,iptables.10和iptables.11都不见了,不知道是什么原因,请各位朋友指点迷津。
[root@S1 log]# ls -l
总计 28111551
-rw-r--r-- 1 root root 672768981 03-01 10:46 iptables
-rw-r--r-- 1 root root 3126740984 03-01 00:01 iptables.1
-rw-r--r-- 1 root root 2254815193 02-18 00:01 iptables.12
-rw-r--r-- 1 root root 3186926177 02-28 00:01 iptables.2
-rw-r--r-- 1 root root 3004102337 02-27 00:01 iptables.3
-rw-r--r-- 1 root root 3049559214 02-26 00:01 iptables.4
-rw-r--r-- 1 root root 2537094127 02-25 00:01 iptables.5
-rw-r--r-- 1 root root 2867791525 02-24 00:01 iptables.6
-rw-r--r-- 1 root root 2753395007 02-23 00:01 iptables.7
-rw-r--r-- 1 root root 2676117769 02-22 00:01 iptables.8
-rw-r--r-- 1 root root 2628795239 02-21 00:01 iptables.9
----------------------
谢谢! |
|