logrotate rotates daily instead of weekly

General support questions
codeology
Posts: 4
Joined: 2017/09/25 14:51:36

logrotate rotates daily instead of weekly

Postby codeology » 2017/10/15 03:01:49

Hello,

I have set /etc/logrotate.conf (details below) to rotate once a week, but it continues to rotate logs daily.

It started to behave like this after I changed the rotate number from default 4 to 10, and later back to 4.

A logrotate script is in the /etc/cron.daily folder, but I don't think it is the cause of the problem.

What did I do wrong? Should I empty the file /var/lib/logrotate/logrotate.status to reset its references?

Thank you all!

Code: Select all

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

# keep 4 weeks worth of backlogs (Default: 4)
rotate 4

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

# use date as a suffix of the rotated file
dateext

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

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

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

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

# system-specific logs may be also be configured here.

codeology
Posts: 4
Joined: 2017/09/25 14:51:36

Re: logrotate rotates daily instead of weekly

Postby codeology » 2017/10/18 00:56:20

I have found out a solution to the problem. You need to force a rotation everytime after changing the logrotate.conf file to reset its time reference point, with the following command:

Code: Select all

# logrotate -f /etc/logrotate.conf

An exerpt from the logrotate man page also mentions this practice:
-f, --force
Tells logrotate to force the rotation, even if it doesn't think this is necessary. Sometimes this
is useful after adding new entries to a logrotate config file, or if old log files have been removed
by hand, as the new files will be created, and logging will continue correctly.