【问题标题】:Why logrotate did nothing but complained no errors?为什么 logrotate 什么也没做,却没有报错?
【发布时间】:2014-09-15 18:52:18
【问题描述】:

答案对您来说可能很明显,但我开始运行我的第一个 logrotate 实例。 /etc/logrotate.d中的配置

    /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
}

然后我用

测试了它
sudo /usr/sbin/logrotate -dvf /etc/logrotate.d/nginx

得到了关注 读取配置文件 /etc/logrotate.d/nginx 读取 /mnt/nginx/logs/access.log 的配置信息

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

完全没有任何改变。它没有抱怨错误。 你能帮忙吗?

谢谢

【问题讨论】:

    标签: nginx logrotate


    【解决方案1】:

    我犯了一个错误。
    不应使用 -d 选项。
    但既然它是这样操作的,为什么不称之为“干”运行呢?

    【讨论】:

      猜你喜欢
      • 2018-07-04
      • 1970-01-01
      • 2017-02-13
      • 2015-09-19
      • 1970-01-01
      • 2015-12-09
      • 2021-12-21
      • 2018-10-12
      • 2014-12-18
      相关资源
      最近更新 更多