gpt4 book ai didi

linux - Logrotate 不旋转或创建新文件

转载 作者:太空宇宙 更新时间:2023-11-04 11:56:01 25 4
gpt4 key购买 nike

我正在尝试在我的 Ubuntu 服务器上为 apache 设置 logrotate,但是在尝试测试轮换时我不断收到以下错误:

logrotate_script: 4: logrotate_script:  : not found
error: error running shared prerotate script for '/var/log/apache2/*.log '

我已经在调试、详细和强制模式下运行它,但我似乎看不到任何可以明确指出问题的地方,所以我非常感谢任何帮助。

这是我的/etc/logrotate.d/apache2 文件:

/var/log/apache2/*.log {
size 100k
missingok
rotate 14
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
/etc/init.d/apache2 restart > /dev/null;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}

这是运行命令 sudo logrotate -vf/etc/logrotate.d/apache2 的输出:

reading config file /etc/logrotate.d/apache2
Handling 1 logs
rotating pattern: /var/log/apache2/*.log forced from command line (14 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/apache2/access.log
log does not need rotating
considering log /var/log/apache2/access_proxy.log
log needs rotating
considering log /var/log/apache2/error.log
log needs rotating
considering log /var/log/apache2/error_proxy.log
log does not need rotating
considering log /var/log/apache2/other_vhosts_access.log
log needs rotating
rotating log /var/log/apache2/access_proxy.log, log->rotateCount is 14
dateext suffix '-20190122'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/apache2/access_proxy.log.1 does not exist
renaming /var/log/apache2/access_proxy.log.14.gz to /var/log/apache2/access_proxy.log.15.gz (rotatecount 14, logstart 1, i 14),
old log /var/log/apache2/access_proxy.log.14.gz does not exist
renaming /var/log/apache2/access_proxy.log.13.gz to /var/log/apache2/access_proxy.log.14.gz (rotatecount 14, logstart 1, i 13),
old log /var/log/apache2/access_proxy.log.13.gz does not exist
renaming /var/log/apache2/access_proxy.log.12.gz to /var/log/apache2/access_proxy.log.13.gz (rotatecount 14, logstart 1, i 12),
old log /var/log/apache2/access_proxy.log.12.gz does not exist
renaming /var/log/apache2/access_proxy.log.11.gz to /var/log/apache2/access_proxy.log.12.gz (rotatecount 14, logstart 1, i 11),
old log /var/log/apache2/access_proxy.log.11.gz does not exist
renaming /var/log/apache2/access_proxy.log.10.gz to /var/log/apache2/access_proxy.log.11.gz (rotatecount 14, logstart 1, i 10),
old log /var/log/apache2/access_proxy.log.10.gz does not exist
renaming /var/log/apache2/access_proxy.log.9.gz to /var/log/apache2/access_proxy.log.10.gz (rotatecount 14, logstart 1, i 9),
old log /var/log/apache2/access_proxy.log.9.gz does not exist
renaming /var/log/apache2/access_proxy.log.8.gz to /var/log/apache2/access_proxy.log.9.gz (rotatecount 14, logstart 1, i 8),
old log /var/log/apache2/access_proxy.log.8.gz does not exist
renaming /var/log/apache2/access_proxy.log.7.gz to /var/log/apache2/access_proxy.log.8.gz (rotatecount 14, logstart 1, i 7),
old log /var/log/apache2/access_proxy.log.7.gz does not exist
renaming /var/log/apache2/access_proxy.log.6.gz to /var/log/apache2/access_proxy.log.7.gz (rotatecount 14, logstart 1, i 6),
old log /var/log/apache2/access_proxy.log.6.gz does not exist
renaming /var/log/apache2/access_proxy.log.5.gz to /var/log/apache2/access_proxy.log.6.gz (rotatecount 14, logstart 1, i 5),
old log /var/log/apache2/access_proxy.log.5.gz does not exist
renaming /var/log/apache2/access_proxy.log.4.gz to /var/log/apache2/access_proxy.log.5.gz (rotatecount 14, logstart 1, i 4),
old log /var/log/apache2/access_proxy.log.4.gz does not exist
renaming /var/log/apache2/access_proxy.log.3.gz to /var/log/apache2/access_proxy.log.4.gz (rotatecount 14, logstart 1, i 3),
old log /var/log/apache2/access_proxy.log.3.gz does not exist
renaming /var/log/apache2/access_proxy.log.2.gz to /var/log/apache2/access_proxy.log.3.gz (rotatecount 14, logstart 1, i 2),
old log /var/log/apache2/access_proxy.log.2.gz does not exist
renaming /var/log/apache2/access_proxy.log.1.gz to /var/log/apache2/access_proxy.log.2.gz (rotatecount 14, logstart 1, i 1),
old log /var/log/apache2/access_proxy.log.1.gz does not exist
renaming /var/log/apache2/access_proxy.log.0.gz to /var/log/apache2/access_proxy.log.1.gz (rotatecount 14, logstart 1, i 0),
old log /var/log/apache2/access_proxy.log.0.gz does not exist
log /var/log/apache2/access_proxy.log.15.gz doesn't exist -- won't try to dispose of it
rotating log /var/log/apache2/error.log, log->rotateCount is 14
dateext suffix '-20190122'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/apache2/error.log.1 does not exist
renaming /var/log/apache2/error.log.14.gz to /var/log/apache2/error.log.15.gz (rotatecount 14, logstart 1, i 14),
old log /var/log/apache2/error.log.14.gz does not exist
renaming /var/log/apache2/error.log.13.gz to /var/log/apache2/error.log.14.gz (rotatecount 14, logstart 1, i 13),
old log /var/log/apache2/error.log.13.gz does not exist
renaming /var/log/apache2/error.log.12.gz to /var/log/apache2/error.log.13.gz (rotatecount 14, logstart 1, i 12),
old log /var/log/apache2/error.log.12.gz does not exist
renaming /var/log/apache2/error.log.11.gz to /var/log/apache2/error.log.12.gz (rotatecount 14, logstart 1, i 11),
old log /var/log/apache2/error.log.11.gz does not exist
renaming /var/log/apache2/error.log.10.gz to /var/log/apache2/error.log.11.gz (rotatecount 14, logstart 1, i 10),
old log /var/log/apache2/error.log.10.gz does not exist
renaming /var/log/apache2/error.log.9.gz to /var/log/apache2/error.log.10.gz (rotatecount 14, logstart 1, i 9),
old log /var/log/apache2/error.log.9.gz does not exist
renaming /var/log/apache2/error.log.8.gz to /var/log/apache2/error.log.9.gz (rotatecount 14, logstart 1, i 8),
old log /var/log/apache2/error.log.8.gz does not exist
renaming /var/log/apache2/error.log.7.gz to /var/log/apache2/error.log.8.gz (rotatecount 14, logstart 1, i 7),
old log /var/log/apache2/error.log.7.gz does not exist
renaming /var/log/apache2/error.log.6.gz to /var/log/apache2/error.log.7.gz (rotatecount 14, logstart 1, i 6),
old log /var/log/apache2/error.log.6.gz does not exist
renaming /var/log/apache2/error.log.5.gz to /var/log/apache2/error.log.6.gz (rotatecount 14, logstart 1, i 5),
old log /var/log/apache2/error.log.5.gz does not exist
renaming /var/log/apache2/error.log.4.gz to /var/log/apache2/error.log.5.gz (rotatecount 14, logstart 1, i 4),
old log /var/log/apache2/error.log.4.gz does not exist
renaming /var/log/apache2/error.log.3.gz to /var/log/apache2/error.log.4.gz (rotatecount 14, logstart 1, i 3),
old log /var/log/apache2/error.log.3.gz does not exist
renaming /var/log/apache2/error.log.2.gz to /var/log/apache2/error.log.3.gz (rotatecount 14, logstart 1, i 2),
old log /var/log/apache2/error.log.2.gz does not exist
renaming /var/log/apache2/error.log.1.gz to /var/log/apache2/error.log.2.gz (rotatecount 14, logstart 1, i 1),
old log /var/log/apache2/error.log.1.gz does not exist
renaming /var/log/apache2/error.log.0.gz to /var/log/apache2/error.log.1.gz (rotatecount 14, logstart 1, i 0),
old log /var/log/apache2/error.log.0.gz does not exist
log /var/log/apache2/error.log.15.gz doesn't exist -- won't try to dispose of it
rotating log /var/log/apache2/other_vhosts_access.log, log->rotateCount is 14
dateext suffix '-20190122'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/apache2/other_vhosts_access.log.1 does not exist
renaming /var/log/apache2/other_vhosts_access.log.14.gz to /var/log/apache2/other_vhosts_access.log.15.gz (rotatecount 14, logstart 1, i 14),
old log /var/log/apache2/other_vhosts_access.log.14.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.13.gz to /var/log/apache2/other_vhosts_access.log.14.gz (rotatecount 14, logstart 1, i 13),
old log /var/log/apache2/other_vhosts_access.log.13.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.12.gz to /var/log/apache2/other_vhosts_access.log.13.gz (rotatecount 14, logstart 1, i 12),
old log /var/log/apache2/other_vhosts_access.log.12.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.11.gz to /var/log/apache2/other_vhosts_access.log.12.gz (rotatecount 14, logstart 1, i 11),
old log /var/log/apache2/other_vhosts_access.log.11.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.10.gz to /var/log/apache2/other_vhosts_access.log.11.gz (rotatecount 14, logstart 1, i 10),
old log /var/log/apache2/other_vhosts_access.log.10.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.9.gz to /var/log/apache2/other_vhosts_access.log.10.gz (rotatecount 14, logstart 1, i 9),
old log /var/log/apache2/other_vhosts_access.log.9.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.8.gz to /var/log/apache2/other_vhosts_access.log.9.gz (rotatecount 14, logstart 1, i 8),
old log /var/log/apache2/other_vhosts_access.log.8.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.7.gz to /var/log/apache2/other_vhosts_access.log.8.gz (rotatecount 14, logstart 1, i 7),
old log /var/log/apache2/other_vhosts_access.log.7.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.6.gz to /var/log/apache2/other_vhosts_access.log.7.gz (rotatecount 14, logstart 1, i 6),
old log /var/log/apache2/other_vhosts_access.log.6.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.5.gz to /var/log/apache2/other_vhosts_access.log.6.gz (rotatecount 14, logstart 1, i 5),
old log /var/log/apache2/other_vhosts_access.log.5.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.4.gz to /var/log/apache2/other_vhosts_access.log.5.gz (rotatecount 14, logstart 1, i 4),
old log /var/log/apache2/other_vhosts_access.log.4.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.3.gz to /var/log/apache2/other_vhosts_access.log.4.gz (rotatecount 14, logstart 1, i 3),
old log /var/log/apache2/other_vhosts_access.log.3.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.2.gz to /var/log/apache2/other_vhosts_access.log.3.gz (rotatecount 14, logstart 1, i 2),
old log /var/log/apache2/other_vhosts_access.log.2.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.1.gz to /var/log/apache2/other_vhosts_access.log.2.gz (rotatecount 14, logstart 1, i 1),
old log /var/log/apache2/other_vhosts_access.log.1.gz does not exist
renaming /var/log/apache2/other_vhosts_access.log.0.gz to /var/log/apache2/other_vhosts_access.log.1.gz (rotatecount 14, logstart 1, i 0),
old log /var/log/apache2/other_vhosts_access.log.0.gz does not exist
log /var/log/apache2/other_vhosts_access.log.15.gz doesn't exist -- won't try to dispose of it
running prerotate script
logrotate_script: 4: logrotate_script: : not found
error: error running shared prerotate script for '/var/log/apache2/*.log '

非常感谢任何帮助,谢谢:)

编辑:碰撞

最佳答案

这有点令人困惑,但是/etc/logrotate.d/httpd-prerotate 是您尝试执行的文件吗?每运行零件 man

run−parts [−−test] [−−verbose] [−−report] [−−lsbsysinit] [−−regex=RE] [−−umask=umask] [−−arg=argument] [−−exit−on−error] [−−help] [−−version] [−−list] [−−reverse] [−−] DIRECTORY

如果您将单个文件传递给 run-parts,它不会知道如何处理它。只需将该文件设置为可执行文件并直接调用它,即

prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then
/etc/logrotate.d/httpd-prerotate;
fi;
endscript

关于linux - Logrotate 不旋转或创建新文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54311989/

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