O Logrotate não roda o log enquanto diz que não

1

Eu tenho uma configuração de logrotate que funcionava normalmente, até que, de repente, parou de fazer isso. Eu acho que parou de girar meu log depois que eu deletei e recriou a pasta log enquanto atualizava meu aplicativo. Abaixo estão as partes relevantes do log de configuração e logrotate.

/etc/logrotate.conf

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0660 root utmp
    rotate 1
}

# system-specific logs may be configured here
/var/lib/redmine/log/production.log{
    daily
    rotate 30
    compress
    delaycompress
    missingok
    notifempty
}

Depois de executar manualmente o logrotate:

rotating pattern: /var/lib/redmine/log/production.log after 1 days (30 rotations)
empty log files are not rotated, old logs are removed
considering log /var/lib/redmine/log/production.log
  log needs rotating
rotating log /var/lib/redmine/log/production.log, log->rotateCount is 30
dateext suffix '-20151209'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
compressing log with: /bin/gzip
renaming /var/lib/redmine/log/production.log.30.gz to /var/lib/redmine/log/production.log.31.gz (rotatecount 30, logstart 1, i 30),
renaming /var/lib/redmine/log/production.log.29.gz to /var/lib/redmine/log/production.log.30.gz (rotatecount 30, logstart 1, i 29),
renaming /var/lib/redmine/log/production.log.28.gz to /var/lib/redmine/log/production.log.29.gz (rotatecount 30, logstart 1, i 28),
renaming /var/lib/redmine/log/production.log.27.gz to /var/lib/redmine/log/production.log.28.gz (rotatecount 30, logstart 1, i 27),
renaming /var/lib/redmine/log/production.log.26.gz to /var/lib/redmine/log/production.log.27.gz (rotatecount 30, logstart 1, i 26),
renaming /var/lib/redmine/log/production.log.25.gz to /var/lib/redmine/log/production.log.26.gz (rotatecount 30, logstart 1, i 25),
renaming /var/lib/redmine/log/production.log.24.gz to /var/lib/redmine/log/production.log.25.gz (rotatecount 30, logstart 1, i 24),
renaming /var/lib/redmine/log/production.log.23.gz to /var/lib/redmine/log/production.log.24.gz (rotatecount 30, logstart 1, i 23),
renaming /var/lib/redmine/log/production.log.22.gz to /var/lib/redmine/log/production.log.23.gz (rotatecount 30, logstart 1, i 22),
renaming /var/lib/redmine/log/production.log.21.gz to /var/lib/redmine/log/production.log.22.gz (rotatecount 30, logstart 1, i 21),
renaming /var/lib/redmine/log/production.log.20.gz to /var/lib/redmine/log/production.log.21.gz (rotatecount 30, logstart 1, i 20),
renaming /var/lib/redmine/log/production.log.19.gz to /var/lib/redmine/log/production.log.20.gz (rotatecount 30, logstart 1, i 19),
renaming /var/lib/redmine/log/production.log.18.gz to /var/lib/redmine/log/production.log.19.gz (rotatecount 30, logstart 1, i 18),
renaming /var/lib/redmine/log/production.log.17.gz to /var/lib/redmine/log/production.log.18.gz (rotatecount 30, logstart 1, i 17),
renaming /var/lib/redmine/log/production.log.16.gz to /var/lib/redmine/log/production.log.17.gz (rotatecount 30, logstart 1, i 16),
renaming /var/lib/redmine/log/production.log.15.gz to /var/lib/redmine/log/production.log.16.gz (rotatecount 30, logstart 1, i 15),
renaming /var/lib/redmine/log/production.log.14.gz to /var/lib/redmine/log/production.log.15.gz (rotatecount 30, logstart 1, i 14),
renaming /var/lib/redmine/log/production.log.13.gz to /var/lib/redmine/log/production.log.14.gz (rotatecount 30, logstart 1, i 13),
renaming /var/lib/redmine/log/production.log.12.gz to /var/lib/redmine/log/production.log.13.gz (rotatecount 30, logstart 1, i 12),
renaming /var/lib/redmine/log/production.log.11.gz to /var/lib/redmine/log/production.log.12.gz (rotatecount 30, logstart 1, i 11),
renaming /var/lib/redmine/log/production.log.10.gz to /var/lib/redmine/log/production.log.11.gz (rotatecount 30, logstart 1, i 10),
renaming /var/lib/redmine/log/production.log.9.gz to /var/lib/redmine/log/production.log.10.gz (rotatecount 30, logstart 1, i 9),
renaming /var/lib/redmine/log/production.log.8.gz to /var/lib/redmine/log/production.log.9.gz (rotatecount 30, logstart 1, i 8),
renaming /var/lib/redmine/log/production.log.7.gz to /var/lib/redmine/log/production.log.8.gz (rotatecount 30, logstart 1, i 7),
renaming /var/lib/redmine/log/production.log.6.gz to /var/lib/redmine/log/production.log.7.gz (rotatecount 30, logstart 1, i 6),
renaming /var/lib/redmine/log/production.log.5.gz to /var/lib/redmine/log/production.log.6.gz (rotatecount 30, logstart 1, i 5),
renaming /var/lib/redmine/log/production.log.4.gz to /var/lib/redmine/log/production.log.5.gz (rotatecount 30, logstart 1, i 4),
renaming /var/lib/redmine/log/production.log.3.gz to /var/lib/redmine/log/production.log.4.gz (rotatecount 30, logstart 1, i 3),
renaming /var/lib/redmine/log/production.log.2.gz to /var/lib/redmine/log/production.log.3.gz (rotatecount 30, logstart 1, i 2),
renaming /var/lib/redmine/log/production.log.1.gz to /var/lib/redmine/log/production.log.2.gz (rotatecount 30, logstart 1, i 1),
renaming /var/lib/redmine/log/production.log.0.gz to /var/lib/redmine/log/production.log.1.gz (rotatecount 30, logstart 1, i 0),
renaming /var/lib/redmine/log/production.log to /var/lib/redmine/log/production.log.1
creating new /var/lib/redmine/log/production.log mode = 0644 uid = 1000 gid = 1000
removing old log /var/lib/redmine/log/production.log.31.gz
error: error opening /var/lib/redmine/log/production.log.31.gz: No such file or directory

Depois de listar o diretório de log:

ll /var/lib/redmine/log/
total 178484
drwxrwxr-x  2 redmine redmine      4096 Dec  9 12:05 ./
drwxr-xr-x 20 redmine redmine      4096 Dec  6 23:56 ../
-rw-rw-r--  1 redmine redmine     49581 Dec  8 14:47 development.log
-rw-r--r--  1 redmine redmine 182700709 Dec  9 12:05 production.log

Então, ele diz que rodou o arquivo de log, mas nada aconteceu. Qual pode ser a razão disso?

    
por svz 09.12.2015 / 10:10

2 respostas

0

O problema passou a ser permissões erradas na pasta log . Logrotate não iria processá-lo porque tinha acesso de escrita de grupo. Depois de executar chmod 755 na pasta de log, tudo começou a funcionar.

    
por 21.12.2015 / 08:25
1

Um motivo pode ser que você esteja listando seus logs como o usuário redmine, enquanto o logrotate funciona como root, então a listagem do diretório não os mostra

Eu preferiria criar o arquivo /etc/logrotate.d/redmine Com os seguintes conteúdos:

/path/to/your/redmine/log/production.log {
daily
missingok
rotate 31
compress
delaycompress
notifempty
copytruncate
} 

Em seguida, teste por:

sudo /usr/sbin/logrotate -f /etc/logrotate.d/redmine
    
por 17.12.2015 / 18:18