Skip to content

Fix invalid Systemd OnCalendar syntax (Issue #3) - #9

Open
jochym wants to merge 1 commit into
different-ai:mainfrom
jochym:fix/issue-3-systemd-oncalendar-syntax
Open

Fix invalid Systemd OnCalendar syntax (Issue #3)#9
jochym wants to merge 1 commit into
different-ai:mainfrom
jochym:fix/issue-3-systemd-oncalendar-syntax

Conversation

@jochym

@jochym jochym commented Mar 6, 2026

Copy link
Copy Markdown

Summary

This PR fixes an issue where the OnCalendar syntax for systemd timers was generated incorrectly when the weekday was not specified (represented by *).

Changes

  • Updated cronToSystemdCalendars in src/index.ts to conditionally include the weekday in the OnCalendar string.
  • According to systemd.time(7), the weekday should be omitted if it is not specifically required, as systemd does not accept * as a valid weekday specifier in this context.

Verification

  • Verified that 0 9 * * * (daily at 09:00) now correctly generates OnCalendar=*-*-* 09:00:00 (previously * *-*-* 09:00:00).
  • Verified that 30 8 * * 1 (Mondays at 08:30) correctly generates OnCalendar=Mon *-*-* 08:30:00.
  • Validated the new syntax using systemd-analyze calendar.
  • Confirmed that the project builds successfully with bun run build.

Fixes #3

@jochym

jochym commented Mar 6, 2026

Copy link
Copy Markdown
Author

You can check the copilot review of the same change here: jochym#1
I think the comment there is not correct, but judge for yourself.

@jochym

jochym commented Mar 7, 2026

Copy link
Copy Markdown
Author

@benjaminshafii can you look at this fix and maybe merge it? This is a small change.

@johnnyasantoss

Copy link
Copy Markdown

lgtm
/cc @benjaminshafii

@legacycode

Copy link
Copy Markdown

Verified ✓

Independently verified this fix — the behavior is exactly as described.
Running systemd-analyze calendar confirms it:

$ systemd-analyze calendar "* *-*-* 09:00:00"
Invalid argument ✗
$ systemd-analyze calendar "*-*-* 09:00:00"
OK — daily at 09:00 ✓
$ systemd-analyze calendar "Mon *-*-* 08:30:00"
OK — Mondays at 08:30 ✓

The fix is correct and aligns with systemd.time(7).
lgtm — hope this gets merged soon, it's a real-world breakage for anyone relying on daily timers.
Thanks @jochym for the clean fix!
/cc @benjaminshafii

@vr-one

vr-one commented Apr 3, 2026

Copy link
Copy Markdown

@jochym @benjaminshafii Thanks for the fix! Anying speaking against merging this change and release it?

@v1b3coder

Copy link
Copy Markdown

I confirm this is problem for systemd users. This PR works. Please merge.

@sharadregoti

Copy link
Copy Markdown

Please merge this PR

@jasondilworth56

Copy link
Copy Markdown

Would love to see this go in @benjaminshafii if you can get to it.

ageless-h added a commit to ageless-h/opencode-scheduler that referenced this pull request Aug 1, 2026
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

Successfully merging this pull request may close these issues.

Invalid systemd OnCalendar syntax that causes timers to fail

7 participants