为什么我仍然看到旧的日志文件而没有新的日志文件?

为什么我仍然看到旧的日志文件而没有新的日志文件?

这是我的设置 logrotate

 /home/sy/logs/kitxit*/*/tend.log
    {
        daily
        rotate 10
        dateext
        compress
        delaycompress
        copytruncate
        missingok
        notifempty
        su apache apache
    }

输出如下

drwxr-xr-x 2 apache apache     4096 Apr 30 13:00 .
drwxr-xr-x 6 apache apache     4096 Apr 30 13:00 ..
-rw-r--r-- 1 apache apache 21318609 May  2 21:25 tend.log
-rw-r--r-- 1 apache apache     4091 Feb 24 03:02 tend.log-20200224.gz
-rw-r--r-- 1 apache apache     4065 Feb 25 03:02 tend.log-20200225.gz
-rw-r--r-- 1 apache apache     4460 Feb 26 03:03 tend.log-20200226.gz
-rw-r--r-- 1 apache apache     4049 Feb 27 03:03 tend.log-20200227.gz
-rw-r--r-- 1 apache apache     2619 Feb 28 03:03 tend.log-20200228.gz
-rw-r--r-- 1 apache apache     1312 Feb 29 03:03 tend.log-20200229.gz
-rw-r--r-- 1 apache apache     1339 Mar  1 03:03 tend.log-20200301.gz
-rw-r--r-- 1 apache apache     1305 Mar  2 03:03 tend.log-20200302.gz
-rw-r--r-- 1 apache apache     2669 Mar  3 03:02 tend.log-20200303.gz
-rw-r--r-- 1 apache apache    70011 Mar  4 03:03 tend.log-20200304

为什么我仍然看到旧的日志文件而没有新的日志文件?

这是调试模式的结果

 [root@xavs-ken logrotate.d]# logrotate -dv kitxit-tend-sylog
reading config file kitxit-tend-sylog
Allocating hash table for state file, size 15360 B

Handling 1 logs

rotating pattern: /home/sy/logs/kitxit*/*/tend/*.log
/home/sy/logs/kitxit*/*/sylog/*.log
 after 1 days (10 rotations)
empty log files are not rotated, old logs are removed
switching euid to 48 and egid to 48
considering log /home/sy/logs/kitxit2/bola/tend/sql.log
  log needs rotating
considering log /home/sy/logs/kitxit2/bola/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/bola/tend/mem.log
  log does not need rotating (log is empty)considering log /home/sy/logs/kitxit/bola/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/clpl/tend/sql.log
  log needs rotating
considering log /home/sy/logs/kitxit/clpl/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/mol/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/pola/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/solsa/tend/sql.log
  log needs rotating
considering log /home/sy/logs/kitxit/solsa/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/sario/tend/mem.log
  log does not need rotating (log is empty)considering log /home/sy/logs/kitxit/sario/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/sasu/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/kilo/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/mixi/tend/mem.log
  log does not need rotating (log is empty)considering log /home/sy/logs/kitxit/mixi/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/aziz/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit/xondana/tend/tend.log
  log needs rotating
considering log /home/sy/logs/kitxit2/bola/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/bola/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/clpl/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/mol/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/pola/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/solsa/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/entag/sylog/action.log
  log does not need rotating (log is empty)considering log /home/sy/logs/kitxit/sario/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/sasu/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/kilo/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/mixi/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/aziz/sylog/action.log
  log needs rotating
considering log /home/sy/logs/kitxit/xondana/sylog/action.log
  log needs rotating
rotating log /home/sy/logs/kitxit2/bola/tend/sql.log, log->rotateCount is 10
dateext suffix '-20200503'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding logs to compress failed
copying /home/sy/logs/kitxit2/bola/tend/sql.log to /home/sy/logs/kitxit2/bola/tend/sql.log-20200503
truncating /home/sy/logs/kitxit2/bola/tend/sql.log
rotating log /home/sy/logs/kitxit2/bola/tend/tend.log, log->rotateCount is 10
dateext suffix '-20200503'
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

...

答案1

调试输出中的日志文件与配置文件中的logrotate路径不对应。

tend.log调试输出中匹配的文件

considering log /home/sy/logs/kitxit2/bola/tend/tend.log
considering log /home/sy/logs/kitxit/clpl/tend/tend.log
considering log /home/sy/logs/kitxit/mol/tend/tend.log
considering log /home/sy/logs/kitxit/pola/tend/tend.log
considering log /home/sy/logs/kitxit/solsa/tend/tend.log
considering log /home/sy/logs/kitxit/sasu/tend/tend.log
considering log /home/sy/logs/kitxit/kilo/tend/tend.log
considering log /home/sy/logs/kitxit/aziz/tend/tend.log
considering log /home/sy/logs/kitxit/xondana/tend/tend.log

日志轮转配置

/home/sy/logs/kitxit*/*/tend.log

该模式需要修改如下以匹配正在考虑的文件,即与*/路径中的另一个文件

/home/sy/logs/kitxit*/*/*/tend.log

由于调试输出中引用了您的目标文件,我猜测某个地方还有另一个 logrotate 片段在 3 月 4 日/5 日左右停止工作。

相关内容