gpt4 book ai didi

ubuntu - logrotate: 打开 .gz 时出错

转载 作者:太空宇宙 更新时间:2023-11-03 16:53:02 25 4
gpt4 key购买 nike

我现在正在 ubuntu 上设置 logrotate 来轮转日志。这是我的配置:

/etc/logrotate.d/test:

/var/log/test/*.log{
weekly
rotate 7
compress
delaycompress
notifempty
create 640 testuser testgroup
}

在/var/log/test 中,它有以下测试日志文件:

-rw-r--r--  1 testuser testgroup 0 四月  1 00:00 2018-04-01.log
-rw-r--r-- 1 testuser testgroup 0 四月 1 00:00 2018-04-02.log
-rw-r--r-- 1 testuser testgroup 0 四月 1 00:00 2018-04-03.log
-rw-r--r-- 1 testuser testgroup 0 四月 1 00:00 2018-04-04.log
-rw-r--r-- 1 testuser testgroup 0 四月 1 00:00 2018-04-05.log
-rw-r--r-- 1 testuser testgroup 0 四月 1 00:00 2018-04-06.log
-rw-r--r-- 1 testuser testgroup 39 四月 1 00:00 2018-04-08.log
-rw-r--r-- 1 testuser testgroup 0 四月 1 00:00 2018-04-09.log
-rw-r--r-- 1 testuser testgroup 391938 四月 1 00:00 scheduler.log

当我运行 logrotate -d -v test 时,它告诉我没有所有日志不需要轮换:

reading config file zctest

Handling 1 logs

rotating pattern: /var/log/test/*.log weekly (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/test/2018-04-01.log
log does not need rotating
considering log /var/log/test/2018-04-02.log
......
considering log /var/log/test/2018-04-02.log

当我运行 logrotate -d -v test -f 时,出现如下错误:

renaming /var/log/KeyServer/2018-04-08.log.1.gz to 
/var/log/KeyServer/2018-04-08.log.2.gz (rotatecount 7, logstart 1, i 1),
renaming /var/log/KeyServer/2018-04-08.log.0.gz to
/var/log/KeyServer/2018-04-08.log.1.gz (rotatecount 7, logstart 1, i 0),
renaming /var/log/KeyServer/2018-04-08.log to /var/log/KeyServer/2018-04-08.log.1
creating new /var/log/KeyServer/2018-04-08.log mode = 0640 uid = 1000 gid = 1000
removing old log /var/log/KeyServer/2018-04-08.log.8.gz
error: error opening /var/log/KeyServer/2018-04-08.log.8.gz: No such file or directory

谁能帮我解决这个问题?

最佳答案

我不知道您是否将 missingok 作为您的 logrotate.conf 文件中的默认参数,但如果没有它,logrotate 将提示那些丢失的文件。参见 man logrotate :

missingok

If the log file is missing, go on to the next one without issuing an error message.

关于ubuntu - logrotate: 打开 <log>.gz 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49790128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com