Logrotate non ruoterà il registro mentre lo dice


1

Ho una configurazione logrotate che ha funzionato normalmente, fino a quando all'improvviso ha smesso di farlo. Immagino che abbia smesso di ruotare il mio registro dopo che ho eliminato e ricreato la logcartella durante l'aggiornamento della mia applicazione. Di seguito sono riportate le parti rilevanti del registro di configurazione 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
}

Dopo aver eseguito manualmente 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

Dopo aver elencato la directory di registro:

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

Quindi dice che ha ruotato il file di registro, ma in realtà non è successo nulla. Quale può essere la ragione?

Risposte:


1

Un motivo potrebbe essere che stai elencando i tuoi log come utente Redmine, mentre logrotate funziona come root, quindi l'elenco delle directory non li mostra

Preferirei creare il file /etc/logrotate.d/redmine con i seguenti contenuti:

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

Quindi prova con:

sudo /usr/sbin/logrotate -f /etc/logrotate.d/redmine

Bene, questo non era il motivo, ma alla fine mi ha aiutato a identificarlo. Il problema riguardava autorizzazioni errate per la logcartella. Ho avuto -waccesso al gruppo per questo. Dopo chmod 755tutto ha iniziato a funzionare.
svz,

0

Il problema si è rivelato essere autorizzazioni errate sulla logcartella. Logrotate non lo elaborerebbe perché aveva accesso in scrittura al gruppo. Dopo aver eseguito chmod 755la cartella di registro, tutto ha iniziato a funzionare.

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.