免费注册 查看新帖 |

Chinaunix

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

[桌面系统] 学习logrotate时,执行出现错误,只能用logrotate -vf /etc/logrotate.conf [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-08-05 12:17 |只看该作者 |倒序浏览
本帖最后由 feitat 于 2012-08-05 12:25 编辑

大家好,我最近在学logrotate,也是用鸟哥的教程,但是在执行自定义的日志轮询的时候,使用的命令出错,只能用logrotate -vf /etc/logrotate.conf来执行我放在logrotate.d下面的admin文件,直接用 logrotate -vf /etc/logrotate.d/admin,就出错,但是鸟哥的书上明明是对的。为什么呢。服务重启和其它设置没有问题。试过好多次了。有点不理解。请大家帮忙看一下

图1:直接用 logrotate -vf /etc/logrotate.d/admin,就出错



下面这个是鸟哥的linux私房菜(第三版)电子版里的配置,他的命令执行是成功的。
[root@www ~]# logrotate -vf /etc/logrotate.d/admin
reading config file /etc/logrotate.d/admin
reading config info for /var/log/admin.log

Handling 1 logs

rotating pattern: /var/log/admin.log  forced from command line (5 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/admin.log
  log needs rotating
rotating log /var/log/admin.log, log->rotateCount is 5
renaming /var/log/admin.log.5.gz to /var/log/admin.log.6.gz (rotatecount 5, logstart 1, i 5),
old log /var/log/admin.log.5.gz does not exist
renaming /var/log/admin.log.4.gz to /var/log/admin.log.5.gz (rotatecount 5, logstart 1, i 4),
old log /var/log/admin.log.4.gz does not exist
renaming /var/log/admin.log.3.gz to /var/log/admin.log.4.gz (rotatecount 5, logstart 1, i 3),
old log /var/log/admin.log.3.gz does not exist
renaming /var/log/admin.log.2.gz to /var/log/admin.log.3.gz (rotatecount 5, logstart 1, i 2),
old log /var/log/admin.log.2.gz does not exist
renaming /var/log/admin.log.1.gz to /var/log/admin.log.2.gz (rotatecount 5, logstart 1, i 1),
old log /var/log/admin.log.1.gz does not exist
renaming /var/log/admin.log.0.gz to /var/log/admin.log.1.gz (rotatecount 5, logstart 1, i 0),
old log /var/log/admin.log.0.gz does not exist
log /var/log/admin.log.6.gz doesn't exist -- won't try to dispose of it
running prerotate script
renaming /var/log/admin.log to /var/log/admin.log.1
running postrotate script
compressing log with: /bin/gzip
这里没有出现提示error等错误,请大家对比一下我上传的图片里的最后两行输入结果。

[root@www ~]# lsattr /var/log/admin.log*
-----a------- /var/log/admin.log
------------- /var/log/admin.log.1.gz  <==有压缩过喔! 我的执行结果是没有压缩的(请看下图),只有直接用logrotate -vf /etc/logrotate.conf 才会有。不知道为什么


您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP