azlux / log2ram

ramlog like for systemd (Put log into a ram folder)
MIT License
2.65k stars 195 forks source link

Changeing timer does not work #214

Closed spacemanspiff2007 closed 1 year ago

spacemanspiff2007 commented 1 year ago

I tried changing the sync interval to weekly following the description:

sudo systemctl edit log2ram-daily.timer
### Editing /etc/systemd/system/log2ram-daily.timer.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Unit]
Description=Daily Log2Ram writing activities

[Timer]
OnCalendar=Sun *-*-* 3:55:00
Persistent=true

[Install]
WantedBy=timers.target

### Lines below this comment will be discarded

### /etc/systemd/system/log2ram-daily.timer
# [Unit]
# Description=Daily Log2Ram writing activities
# 
# [Timer]
# OnCalendar=*-*-* 23:55:00
# Persistent=true
# 
# [Install]
# WantedBy=timers.target
systemctl list-timers
Fri 2023-10-20 23:55:00 CEST 18h left       Fri 2023-10-20 05:35:03 CEST 15min ago         log2ram-daily.timer          log2ram-daily.service

Somehow the timer does not get picked up. What am I doing wrong?

peterpepo commented 1 year ago

Please add OnCalendar= above your OnCalendar=Sun *-*-* 3:55:00 as instructed in README - https://github.com/azlux/log2ram#refresh-time.

As explained here, https://bbs.archlinux.org/viewtopic.php?pid=1642051#p1642051, values in override are "summed" with values in original timer file, thus the OnCalendar must be cleared first.

Timers are cumulative, so in the override you need to reset the existing timers otherwise your OnCalendar setting gets added to the existing one.

For the very same reason, you can remove [Unit] and [Install] sections altogether from your override file. Leave just the [Timer] there.

I have tested this on my machine

[Timer]
OnCalendar=
OnCalendar=Sun *-*-* 3:55:00

=>

pi@raspberrypi:~ $ sudo systemctl list-timers --all
NEXT                         LEFT          LAST                         PASSED       UNIT                         ACTIVATES
Sun 2023-10-29 03:55:00 CET  3 days left   Tue 2023-10-24 23:55:02 CEST 9h ago       log2ram-daily.timer          log2ram-daily.service
spacemanspiff2007 commented 1 year ago

Thank you for your help - it works now as expected