Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd timers don't work properly with non-default time periods #99

Open
automorphism88 opened this issue Dec 1, 2021 · 1 comment

Comments

@automorphism88
Copy link

I changed the scrub period in /etc/sysconfig/btrfsmaintenance from monthly to weekly, and it seems that when using systemd timers, btrfsmaintenance-refresh.service implements this change by creating a file/etc/systemd/system/btrfs-scrub-timer.d/schedule.conf to make the timer trigger weekly. However, it seems the effect is to make the timer start both monthly and weekly. I noticed that it activated today on the 1st of the month, even though it had just activated two days ago at the beginning of the week. I don't believe that that is the intended behavior, and it only happens with the systemd timers, not if you use cron.

@telkkar
Copy link

telkkar commented Dec 5, 2021

The behavior you're describing sounds like OnCalendar isn't being reset before the directive in the schedule.conf file.

Some references:
See last sentence of systemd.timer
systemd.unit

From systemd.unit specifically:

Note that for drop-in files, if one wants to remove entries from a setting that is parsed as a list (and is not a dependency), such as AssertPathExists= (or e.g. ExecStart= in service units), one needs to first clear the list before re-adding all entries except the one that is to be removed.

I'm not sure how to tell exactly if OnCalendar is a setting that systemd parses as a list, but something like this is probably what the change would look like in btrfsmaintenance-refresh-cron.sh. Note the OnCalendar= line

			mkdir -p /etc/systemd/system/"$SERVICE".timer.d/
			cat << EOF > /etc/systemd/system/"$SERVICE".timer.d/schedule.conf
[Timer]
OnCalendar=
OnCalendar=$PERIOD
EOF
			systemctl enable "$SERVICE".timer &> /dev/null

EDIT1: Looks like this should be addressed by the changes in the devel branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants