Use this when scheduling with systemd timers.
systemd Timers · Bash Automation
systemd timers schedule services with .timer units using OnCalendar= or OnBootSec=, with logging in journald, Persistent=true for missed runs and dependencies, as a modern alternative to cron.
1. systemd timers trigger service units.
2. OnCalendar, Persistent=true for missed runs.
3. Logging in journal.
4. Dependencies and sandboxing.
5. RandomizedDelaySec to spread load.
timer → service unit → journal
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as unquoted expansion, globbing, pipeline status loss, subshell scope, set -e misconceptions, signal races, temporary-file leakage and destructive path ambiguity, choosing the cases most relevant to OnCalendar/monotonic timers, Persistent, RandomizedDelaySec, accuracy, associated service unit and journal/state proving actual dispatch.
Step 2 Common mistakes Narrow the fault
- Forgetting the matching
.serviceunit. - Not enabling the timer.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Pair .timer with .service.
- OnCalendar= for schedules.
- Persistent=true catches missed runs.
systemctl list-timers --all— timerssystemctl status <name>.timer <name>.service— statejournalctl -u <name>.service— run logs
ReferenceWhy it matters1 section · depth on demand
What it is
systemd timers are the modern alternative to cron: a .timer unit triggers a .service unit, with logging in the journal, missed-run catch-up (Persistent=true) and randomised delays.
ReferenceImportant terms & boundaries2 sections · depth on demand
Example
# backup.timer
[Timer]
OnCalendar=*-*-* 02:00
Persistent=true
[Install]
WantedBy=timers.target
systemctl enable --now backup.timer, systemctl list-timers, journalctl -u backup.service.
In depth
systemd timers are the modern way to schedule Bash scripts on Linux. Compared with cron they give journal logging, missed-run catch-up, randomised delays, dependency ordering and resource limits — and systemctl list-timers shows when each job last and next runs.
# disk-report.timer
[Timer]
OnCalendar=hourly
RandomizedDelaySec=5m
Persistent=true
[Install]
WantedBy=timers.target
# disk-report.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/disk-report.sh
systemctl enable --now disk-report.timer
systemctl list-timers --all | grep disk-report
systemctl start disk-report.service # run now for testing
The script's exit code becomes the unit's result, so failures are visible in systemctl --failed and can trigger OnFailure= notifications.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Bash Automation > systemd Timers. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.gnu.org/software/bash/manual/bash.html · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For OnCalendar/monotonic timers, Persistent, RandomizedDelaySec, accuracy, associated service unit and journal/state proving actual dispatch, prefer typed fields and stable IDs over human presentation text.