kdave / btrfsmaintenance

Scripts for btrfs maintenance tasks like periodic scrub, balance, trim or defrag on selected mountpoints or directories.
GNU General Public License v2.0
900 stars 79 forks source link

All systemd timers not set to monthly run 1st of month at 0:00 in addition to PERIOD setting #71

Closed CorrosiveTruths closed 3 years ago

CorrosiveTruths commented 5 years ago

Affects all timers used in btrfsmaintenance.

Using btrfs-trim as an example:

I set the trim to run every Monday at 15:45 with the following setting. /etc/default/btrfsmaintenance BTRFS_TRIM_PERIOD="Monday 15:45"

Ran the refresh script with systemctl restart btrfsmaintenance-refresh

Ran fine at the allotted time, but then when I check the status of the timer.

systemctl status btrfs-trim.timer Loaded: loaded (/lib/systemd/system/btrfs-trim.timer; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/btrfs-trim.timer.d └─schedule.conf Trigger: Fri 2019-02-01 00:00:00 GMT; 3 days left

It will run next on the 1st (Friday) of the month at 0:00.

The timer is sourcing both OnCalendar=monthly from the timer section of /lib/systemd/system/btrfs-trim.timer and OnCalendar=Monday 15:45 from the timer section of /etc/systemd/system/btrfs-trim.timer.d/schedule.conf

Removing the OnCalendar=monthly from the timer section of /lib/systemd/system/btrfs-trim.timer and re-running the refresh script fixes the issue.

That won't persist after the package is updated though, so the workaround I'm using is to copy /lib/systemd/system/btrfs-trim.timer as /etc/systemd/system/btrfs-trim.timer and remove the OnCalendar=monthly from the timer section as systemd will read that file instead of the /lib version.

CorrosiveTruths commented 5 years ago

Continued from #65

CorrosiveTruths commented 4 years ago

Probably easier to reset the OnCalendar in /etc/systemd/system/btrfs-trim.timer.d/schedule.conf.

E.g.: OnCalendar= OnCalendar=Monday 15:45

AndreaPro commented 3 years ago

I've setup btrfsmaintenance on my Debian Buster system and I've noticed that the issue is still there

Seb35 commented 3 years ago

I also observe this. Given OnCalendar= can be specified multiple times (see systemd.timer(5)), the files schedule.conf must indeed be:

[Timer]
OnCalendar=
OnCalendar=Monday 15:45
kdave commented 3 years ago

Fixed by #94.