[LINUX] Pit pits that logs are not rotated in Fedora 33 (beta)

environment Fedora 33(beta) x86_64 cronie-1.5.5-4.fc33.x86_64 cronie-anacron-1.5.5-4.fc33.x86_64 logrotate-3.17.0-3.fc33.x86_64 systemd-246.6-3.fc33.x86_64

Symptoms I want to logrotate hourly, but it doesn't rotate at the expected intervals.

Reproduction procedure (1) Install Fedora 33 (beta) with minimum (2) Install cronie, cronie-anacron, crontabs (3) Install rsyslog and logrotate (4) Regarding rotation of / var / log / messages in /etc/logrotate.d/rsyslog Set the log rotation interval to hourly. (5) Wait a few hours

Prospective result / var / log / messages etc. are rotated every hour.

Actual result / var / log / messages etc. are not rotated after waiting a few hours.

Cause The default way to start logrotate has changed from cron to systemd-timer. Because the default operation interval of logrotate is daily.

Details In the old days logrotate was done from cron / anacron, but nowadays systemd-timer Fedora developers want to take it in the direction of using it to rotate logs There seems to be. Once the logrotate RPM package included /etc/cron.daily/logrotate It was, but

* Wed Nov 21 2018 Alejandro Domínguez Muñoz <[email protected]> - 3.14.0-5
- add make as a build dependency
- replace cron job with a systemd timer unit (#1502085, #1655153)

At that time, it seems that this configuration file is no longer included. Instead, /usr/lib/systemd/system/logrotate.timer, logrotate.service Is included, so you need to enable it.

# systemctl enable logrotate.timer

I wait for a while, but the log rotation is not executed every hour. The cause was the initial setting in logrotate.timer.

/usr/lib/systemd/system/logrotate.timer
OnCalendar = daily 

Because it is, logrotate is started once a day (after midnight) as the initial setting It has become. Therefore, even if hourly is written in the logrotate configuration file Log rotation was not performed because logrotate was not executed every hour.

How to fix

# cp /usr/lib/systemd/system/logrotate.timer /etc/systemd/system/
# cp /usr/lib/systemd/system/logrotate.service /etc/systemd/system/
# vi /etc/systemd/system/logrotate.timer
Before correction: OnCalendar=daily
Revised: OnCalendar=hourly

# systemctl daemon-reload
# systemctl enable logrotate.timer

This is the expected move.

reference https://bugzilla.redhat.com/show_bug.cgi?id=1757726

Recommended Posts

Pit pits that logs are not rotated in Fedora 33 (beta)
About the matter that the contents of Python print are not visible in docker logs
Upload and manage packages that are not in conda to anaconda.org