Logrotate question
by skagnola from LinuxQuestions.org on (#534K5)
I have a logrotate config that I do not believe is actually doing its rotate as expected. This is in Centos 7.6
Code:/path/to/file/test.log
{
weekly
rotate 25
notifempty
missingok
copytruncate
nocreate
su user group
}Is 'nocreate' shooting itself in the foot? It appears that it will do its thing... but when I search this directory after a week, there are no copies of the old log file. The initial log file remains and continues to grow.
What I'm seeing in the dry-run of logrotate
Code:rotating pattern: /path/to/file/test.log weekly (25 rotations)
empty log files are not rotated, old logs are removed
switching euid to 1001 and egid to 1001
considering log /path/to/file/test.log
log needs rotating
rotating log /path/to/file/test.log, log->rotateCount is 25
dateext suffix '-20200506'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /path/to/file/test.log.25.gz to /path/to/file/test.log.26.gz (rotatecount 25, logstart 1, i 25),
renaming /path/to/file/test.log.24.gz to /path/to/file/test.log.25.gz (rotatecount 25, logstart 1, i 24),
...
renaming /path/to/file/test.log.1.gz to /path/to/file/test.log.2.gz (rotatecount 25, logstart 1, i 1),
renaming /path/to/file/test.log.0.gz to /path/to/file/test.log.1.gz (rotatecount 25, logstart 1, i 0),
copying /path/to/file/test.log to /path/to/file/test.log.1
truncating /path/to/file/test.log
compressing log with: /bin/gzip
removing old log /path/to/file/test.log.26.gz
error: error opening /path/to/file/test.log.26.gz: No such file or directory
switching euid to 0 and egid to 0
The /etc/cron.daily/logrotate looks like so
Code:#!/bin/sh
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0


Code:/path/to/file/test.log
{
weekly
rotate 25
notifempty
missingok
copytruncate
nocreate
su user group
}Is 'nocreate' shooting itself in the foot? It appears that it will do its thing... but when I search this directory after a week, there are no copies of the old log file. The initial log file remains and continues to grow.
What I'm seeing in the dry-run of logrotate
Code:rotating pattern: /path/to/file/test.log weekly (25 rotations)
empty log files are not rotated, old logs are removed
switching euid to 1001 and egid to 1001
considering log /path/to/file/test.log
log needs rotating
rotating log /path/to/file/test.log, log->rotateCount is 25
dateext suffix '-20200506'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
renaming /path/to/file/test.log.25.gz to /path/to/file/test.log.26.gz (rotatecount 25, logstart 1, i 25),
renaming /path/to/file/test.log.24.gz to /path/to/file/test.log.25.gz (rotatecount 25, logstart 1, i 24),
...
renaming /path/to/file/test.log.1.gz to /path/to/file/test.log.2.gz (rotatecount 25, logstart 1, i 1),
renaming /path/to/file/test.log.0.gz to /path/to/file/test.log.1.gz (rotatecount 25, logstart 1, i 0),
copying /path/to/file/test.log to /path/to/file/test.log.1
truncating /path/to/file/test.log
compressing log with: /bin/gzip
removing old log /path/to/file/test.log.26.gz
error: error opening /path/to/file/test.log.26.gz: No such file or directory
switching euid to 0 and egid to 0
The /etc/cron.daily/logrotate looks like so
Code:#!/bin/sh
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0