Logrotate não fazendo nenhuma rotação

0

Acabei de configurar o LogRotate no meu servidor RHEL6 para que ele gire meus arquivos de log do Apache personalizados. No entanto, não faz nada quando tento executá-lo manualmente.

Espero que ele gire os arquivos de log "access.log" e "err.log". Eles estão lá há alguns dias e precisam ser rotacionados.

Aqui está a saída:

[root@pc1 httpd]# logrotate -d -f /etc/logrotate.d/apache
reading config file /etc/logrotate.d/apache
reading config info for /var/log/httpd/*log
/var/www/html/NSLogs/access.log
/var/www/html/NSErrorLogs/err.log


Handling 1 logs

rotating pattern: /var/log/httpd/*log
/var/www/html/NSLogs/access.log
/var/www/html/NSErrorLogs/err.log
 forced from command line (no old logs will be kept)
empty log files are rotated, old logs are removed
considering log /var/log/httpd/access_log
  log needs rotating
considering log /var/log/httpd/error_log
  log needs rotating
considering log /var/www/html/NSLogs/access.log
  log needs rotating
considering log /var/www/html/NSErrorLogs/err.log
  log needs rotating
rotating log /var/log/httpd/access_log, log->rotateCount is 0
dateext suffix '-20131023'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
fscreate context set to unconfined_u:object_r:httpd_log_t:s0
renaming /var/log/httpd/access_log to /var/log/httpd/access_log-20131023
disposeName will be /var/log/httpd/access_log-20131023.gz
running postrotate script
running script with arg /var/log/httpd/access_log: "
      /usr/bin/killall -HUP httpd
"
compressing log with: /bin/gzip
removing old log /var/log/httpd/access_log-20131023.gz
error: error opening /var/log/httpd/access_log-20131023.gz: No such file or directory
rotating log /var/log/httpd/error_log, log->rotateCount is 0
dateext suffix '-20131023'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
fscreate context set to unconfined_u:object_r:httpd_log_t:s0
renaming /var/log/httpd/error_log to /var/log/httpd/error_log-20131023
disposeName will be /var/log/httpd/error_log-20131023.gz
running postrotate script
running script with arg /var/log/httpd/error_log: "
      /usr/bin/killall -HUP httpd
"
compressing log with: /bin/gzip
removing old log /var/log/httpd/error_log-20131023.gz
error: error opening /var/log/httpd/error_log-20131023.gz: No such file or directory
rotating log /var/www/html/NSLogs/access.log, log->rotateCount is 0
dateext suffix '-20131023'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
fscreate context set to unconfined_u:object_r:httpd_sys_rw_content_t:s0
renaming /var/www/html/NSLogs/access.log to /var/www/html/NSLogs/access.log-20131023
disposeName will be /var/www/html/NSLogs/access.log-20131023.gz
running postrotate script
running script with arg /var/www/html/NSLogs/access.log: "
      /usr/bin/killall -HUP httpd
"
compressing log with: /bin/gzip
removing old log /var/www/html/NSLogs/access.log-20131023.gz
error: error opening /var/www/html/NSLogs/access.log-20131023.gz: No such file or directory
rotating log /var/www/html/NSErrorLogs/err.log, log->rotateCount is 0
dateext suffix '-20131023'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
fscreate context set to unconfined_u:object_r:httpd_sys_rw_content_t:s0
renaming /var/www/html/NSErrorLogs/err.log to /var/www/html/NSErrorLogs/err.log-20131023
disposeName will be /var/www/html/NSErrorLogs/err.log-20131023.gz
running postrotate script
running script with arg /var/www/html/NSErrorLogs/err.log: "
      /usr/bin/killall -HUP httpd
"
compressing log with: /bin/gzip
removing old log /var/www/html/NSErrorLogs/err.log-20131023.gz
error: error opening /var/www/html/NSErrorLogs/err.log-20131023.gz: No such file or directory
    
por blizz 23.10.2013 / 17:20

2 respostas

1

Eu mudei o formato do arquivo de configuração para o seguinte e ele parece estar funcionando bem agora.

/var/log/httpd/*log
/var/www/html/NSLogs/access.log
/var/www/html/NSErrorLogs/err.log
{
    copytruncate
    daily
    size 500M
    compress
    dateext
    maxage 60
}
    
por 23.10.2013 / 18:25
1

Não tenho certeza se esse é o problema, mas se o Apache ainda estiver em execução, ele poderá ter um bloqueio nesses arquivos de log. Talvez o /usr/bin/killall -HUP httpd não mate o Apache rápido o suficiente.

Tente desligar o Apache primeiro e veja se isso ajuda:

service httpd stop
logrotate -f /etc/logrotate.d/apache
service httpd start

Se você não iniciar o Apache com o serviço, precisará usar o comando apropriado.

BTW. meu /etc/logrotate.d/httpd (que é seu /etc/logrotate.d/apache ) se parece com isto:

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /bin/kill -USR1 'cat /var/run/httpd.pid 2>/dev/null' 2> /dev/null || true
    endscript
}
    
por 23.10.2013 / 17:41