You are not logged in.

#1 2014-11-25 22:05:19

jskier
Member
From: Minnesota, USA
Registered: 2003-07-30
Posts: 383
Website

logrotate with systemd hourly instead of daily [Solved]

Is there a preferred way of creating a timer to do hourly instead of daily for the systemd timer that handles logrotate? Systemd documentation is still a bit messy, so thought I'd see if anyone has done this already before injecting myself with another systemd migraine. I have some beefy IDS and remote syslogs that take copious amounts of minutes to rotate at midnight, which isn't ideal for the file monitor watching the files as things get missed.

I could go the easy route with cron and do all hours except midnight (leaving the systemd timer to pick this up), but I'd like to make this consistent since systemd is the inevitable future.

Thanks in advance for any help,

UPDATE: Ended up creating a logrotate package with hourly timer which handles hourly configs in addition to daily, as well size every hour. I've added this forked logrotate package to AUR if anyone is interested, look for logrotate-hourly.

Last edited by jskier (2014-11-26 16:29:40)


--
JSkier

Offline

#2 2014-11-26 08:04:02

rumpelsepp
Member
From: Bavaria
Registered: 2012-11-13
Posts: 105
Website

Re: logrotate with systemd hourly instead of daily [Solved]

It is well documented how to overwrite units in systemd. Just copy /usr/lib/systemd/system/logrotate.timer to /etc/systemd/system/logrotate.timer and adjust your value. Then hit "systemctl reenable logrotate.timer". "systemd-delta" could be used to view a diff.

But I think the problem here is that the symlink is owned by the pacman package as it is enabled by default...
Maybe you could simply create a timer like this one:

# /etc/systemd/system/logrotate-hourly.timer
[Unit]
Description=Hourly rotation of log files

[Timer]
Unit=logrotate.service
OnCalendar=hourly
Persistent=true

Every time I see some piece of medical research saying that caffeine is good for you, I high-five myself. Because I'm going to live forever. -- Torvalds, Linus (2010-08-03).

Offline

#3 2014-11-26 16:25:58

jskier
Member
From: Minnesota, USA
Registered: 2003-07-30
Posts: 383
Website

Re: logrotate with systemd hourly instead of daily [Solved]

But I think the problem here is that the symlink is owned by the pacman package as it is enabled by default...

Thanks for the suggestion. The fork I put in AUR is pretty much that timer, and conflicts with core lograte package for this reason. So far, hourly and size rotations work on the hour. Since the logrorate package controls the timer, a fork seemed to make the most sense to me.

I also reached out the core logrotate maintainer to get his thoughts on going to hourly for default, as log rotate has hourly configuration options and the daily timer breaks this.


--
JSkier

Offline

Board footer

Powered by FluxBB