Logrotate не вращается или создает новые файлы - PullRequest
0 голосов
/ 22 января 2019

Я пытаюсь настроить logrotate для apache на моем сервере Ubuntu, однако я продолжаю получать следующие ошибки при попытке проверить ротацию:

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 '

Любая помощь очень ценится, спасибо:)

РЕДАКТИРОВАТЬ: bump

1 Ответ

0 голосов
/ 01 марта 2019

Это немного сбивает с толку, но является /etc/logrotate.d/httpd-prerotate файл, который вы пытаетесь выполнить? За пробеги человек

run − parts [−test] [−verbose] [−report] [−−lsbsysinit] [−−regex = RE] [−umask = umask] [−−arg = аргумент] [−− exit-on-error] [−−help] [−−version] [−−list] [−−reverse] [−−] СПРАВОЧНИК

Если вы передаете один файл в run-parts, он не будет знать, что с ним делать. Просто установите этот исполняемый файл и вызовите его напрямую, т.е.

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