Logrotate不旋转或创建新文件

问题描述 投票:0回答:1

我正在尝试在我的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 '

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

编辑:碰撞

linux apache ubuntu logging logrotate
1个回答
0
投票

这有点令人困惑但是/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
© www.soinside.com 2019 - 2024. All rights reserved.