首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么logrotate什么都不做,却不抱怨错误?

为什么logrotate什么都不做,却不抱怨错误?
EN

Stack Overflow用户
提问于 2014-07-24 17:27:36
回答 1查看 3.1K关注 0票数 0

答案对你来说可能是显而易见的,但我开始运行我的第一个logrotate实例。/etc/logrotate.d中的配置

代码语言:javascript
运行
复制
    /mnt/nginx/logs/access.log {
        size 1k
        dateext
        missingok
        rotate 10
        compress
        delaycompress
        notifempty
        create 640 root root 
        sharedscripts
        postrotate
                [ -f /opt/nginx/logs/nginx.pid ] && kill -USR1 `cat /opt/nginx/logs/nginx.pid`
        endscript
}

然后我用以下命令进行了测试

代码语言:javascript
运行
复制
sudo /usr/sbin/logrotate -dvf /etc/logrotate.d/nginx

并获得以下读取配置文件/etc/logrotate.d/nginx读取/mnt/nginx/logs/access.log的配置信息

代码语言:javascript
运行
复制
Handling 1 logs

rotating pattern: /mnt/nginx/logs/access.log  forced from command line (10 rotations)
empty log files are not rotated, old logs are removed
considering log /mnt/nginx/logs/access.log
  log needs rotating
rotating log /mnt/nginx/logs/access.log, log->rotateCount is 10
dateext suffix '-20140724'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding logs to compress failed
glob finding old rotated logs failed
renaming /mnt/nginx/logs/access.log to /mnt/nginx/logs/access.log-20140724
creating new /mnt/nginx/logs/access.log mode = 0640 uid = 0 gid = 0
running postrotate script
running script with arg /mnt/nginx/logs/access.log : "
                [ -f /opt/nginx/logs/nginx.pid ] && kill -USR1 `cat /opt/nginx/logs/nginx.pid`
"


Before test
total 84K
-rw-r--r-- 1 root root 51K Jul 22 15:05 access.log
-rw-r--r-- 1 root root 24K Jul 15 17:02 error.log


After test
total 84K
-rw-r--r-- 1 root root 51K Jul 22 15:05 access.log
-rw-r--r-- 1 root root 24K Jul 15 17:02 error.log

完全没什么变化。而且它也没有抱怨错误。你能帮帮忙吗?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2014-07-25 10:28:02

我犯了一个错。

不应使用-d选项。

但是既然它是这样做的,为什么不叫它“干”运行呢?

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24929947

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档