Bug 1757726

Summary: logrotate no longer runs by default after installation
Product: [Fedora] Fedora Reporter: Ian Donaldson <iand>
Component: logrotateAssignee: Kamil Dudka <kdudka>
Status: CLOSED CANTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 30CC: jkaluza, kdudka, svashisht
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-01-06 13:35:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ian Donaldson 2019-10-02 09:49:18 UTC
Description of problem:

If you install logrotate you find that it doesn't run by default anymore

Version-Release number of selected component (if applicable):

logrotate-3.15.1-1.fc30.x86_64


How reproducible:

100%

Steps to Reproduce:
1. dnf install logrotate
2. come back 24H later
3. note no logs rotated; /var/lib/logrotate is empty

Actual results:

nothing happens

Expected results:

log files rotated

Additional info:

Prior to fc30, when you installed logrotate it created an entry in /etc/cron.daily which caused it to run from then on.

The fc30 package doesn't create this cron entry; it installs a systemd
timer instead but doesn't activate it by default.

/usr/lib/systemd/system/logrotate.service
/usr/lib/systemd/system/logrotate.timer

This requires you to do this after installing logrotate:

systemctl enable logrotate.timer
systemctl start logrotate.timer

Whilst this is an easy workaround, its not backwards compatible with 
prior package behavior, where installation also causes activation,
although arguably other packages tend to not auto enable daemons at systemd
upon install.

I've had to update all my kickstart scripts for this, and also run
around to all fc30 systems I installed months ago and retrospectively
enable logrotate.  (only noticed lack of rotation today when a system
started to run out of disk space)

Systems that were distro-sync upgraded from fc29 to fc30 did however 
end up with logrotate running ok; presumably the upgrade script
did the enabling as part of the upgrade.

Comment 1 Kamil Dudka 2019-10-02 10:23:04 UTC
(In reply to Ian Donaldson from comment #0)
> Prior to fc30, when you installed logrotate it created an entry in
> /etc/cron.daily which caused it to run from then on.

Only if you had any cron daemon configured.

> The fc30 package doesn't create this cron entry; it installs a systemd
> timer instead but doesn't activate it by default.
> 
> /usr/lib/systemd/system/logrotate.service
> /usr/lib/systemd/system/logrotate.timer

Yes, this is expected.

> This requires you to do this after installing logrotate:
> 
> systemctl enable logrotate.timer
> systemctl start logrotate.timer

There is no easy solution to this.  If we enabled logrotate.timer in vendor preset, logrotate would be run unexpectedly on installations where it did not run originally (where cron was not configured).

> Systems that were distro-sync upgraded from fc29 to fc30 did however 
> end up with logrotate running ok; presumably the upgrade script
> did the enabling as part of the upgrade.

Only if you had any cron daemon configured:

https://src.fedoraproject.org/rpms/logrotate/blob/07f59cae/f/logrotate.spec#_93

Comment 2 Ian Donaldson 2019-10-02 11:57:41 UTC
Sure; forgive me I have never come across a *ix system without cron installed; its pretty fundamental; but
I guess there are systems that are setup that way.

Comment 3 Kamil Dudka 2019-10-02 12:13:20 UTC
The related Fedora documentation does not seem to assume cron is always installed:

https://docs.fedoraproject.org/en-US/fedora/f30/system-administrators-guide/monitoring-and-automation/Automating_System_Tasks/

Comment 4 Kamil Dudka 2020-01-06 13:35:52 UTC
It is unclear how this could be improved without introducing any unwanted side-effects.  Closing...