免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2204 | 回复: 2
打印 上一主题 下一主题

logrotate 删除文件问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-03-01 11:00 |只看该作者 |倒序浏览
各位好,我用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

----------------------
谢谢!

招聘 : 技术支持/维
论坛徽章:
0
2 [报告]
发表于 2010-03-01 18:35 |只看该作者
回复 1# solink


    haowan~

论坛徽章:
0
3 [报告]
发表于 2010-03-02 10:30 |只看该作者
晕,你怎么会觉得好玩。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP