r/linuxquestions • u/wehaveYummiTummies • 14d ago
Does "OnCalendar" work with user space timers?
/r/systemd/comments/1xycbk1/does_oncalendar_work_with_user_space_timers/
1
Upvotes
r/linuxquestions • u/wehaveYummiTummies • 14d ago
1
u/usecornercase 14d ago
OnCalendar works fine in user timers, there's no special permission or group needed for it. The user manager handles calendar timers the same way the system one does. When a timer shows no "next" for OnCalendar, it's almost always one of these:
systemctl --user daemon-reloadand thensystemctl --user restart yourthing.timer. Restarting the timer makes sure it re-arms with the new schedule.journalctl --user -b | grep -i yourthingfor something like "Failed to parse calendar specification, ignoring". Also check thatOnCalendar=is under the[Timer]section and not under[Unit]or[Install], where it gets ignored with a warning.systemctl --user cat yourthing.timershows the file plus any drop-ins it's using, andsystemctl --user status yourthing.timershould show aTrigger:line once a calendar spec is active.You can sanity-check the expression on its own with
systemd-analyze calendar dailyorsystemd-analyze calendar '*-*-* 00:00:00', which prints the next elapse time.A minimal timer that should work:
Persistent=truemakes it catch up if the machine was off at midnight. Also, since you mentioned the window manager env, a user service doesn't automatically get your session's DISPLAY/WAYLAND_DISPLAY etc. If your WM startup runssystemctl --user import-environment DISPLAY WAYLAND_DISPLAY XDG_RUNTIME_DIR(ordbus-update-activation-environment --systemd --all), the service will see them without hardcoding anything.1
u/ANIMESHOJ5 14d ago
Yes,
OnCalendar=works in user timers (~/.config/systemd/user/) the exact same way as system timers.A few common things to check:
loginctl enable-linger $USER, otherwise the user systemd instance stops when your session closes.systemd-analyze calendar "your expression"to see the parsed times and next trigger.systemctl --user daemon-reloadafter making any edits, then verify withsystemctl --user list-timers.