Write a systemd service unit and matching timer unit on Linux to run a script on a schedule

domain: freedesktop.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create the service unit file at /etc/systemd/system/myjob.service with sections [Unit] (Description=), [Service] (Type=oneshot, ExecStart=/path/to/script.sh), and optionally [Install].
  2. Create the paired timer file myjob.timer with [Unit], [Timer] (OnCalendar= using a calendar expression such as 'daily' or '*-*-* 02:30:00', Persistent=true to catch missed runs), and [Install] (WantedBy=timers.target).
  3. Enable and start the timer: systemctl enable --now myjob.timer
  4. Check timer status and next trigger: systemctl list-timers --all | grep myjob
  5. View service output: journalctl -u myjob.service -n 50

Known gotchas

Related routes

write and validate complex systemd OnCalendar expressions for timer units using systemd-analyze calendar before deploying them
freedesktop.org · 5 steps · unrated
Run a headless Playwright script on a fixed schedule via cron or a systemd timer
playwright.dev · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans