systemd Timer

systemd Timer

Why systemd Over cron

Concern Resolution

Laptop sleep

Persistent=true — fires missed jobs on wake. cron silently skips them.

Logging

journalctl --user -u chla-code-alert.service — structured, queryable, retained.

No extra packages

Arch does not ship cronie. systemd is already running.

Dependency ordering

Can integrate with other user units if needed.

Files

File Purpose

~/.config/systemd/user/chla-code-alert.service

Oneshot service — runs the alert script

~/.config/systemd/user/chla-code-alert.timer

Timer — weekdays 08:07 + 14:17, persistent, 2-minute jitter

Management Commands

# Check timer status and next fire time
systemctl --user status chla-code-alert.timer

# List all user timers
systemctl --user list-timers

# Manual trigger (test the full chain)
systemctl --user start chla-code-alert.service

# View logs
journalctl --user -u chla-code-alert.service --since today

# Reload after editing .service or .timer
systemctl --user daemon-reload

# Disable temporarily
systemctl --user stop chla-code-alert.timer

# Re-enable
systemctl --user start chla-code-alert.timer

Wayland DBUS

Cron and systemd services run outside the graphical session. notify-send requires DBUS_SESSION_BUS_ADDRESS to reach the compositor. The service unit sets this explicitly:

Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus

The script also sets a fallback in case it is run directly.