code · Nov 12, 2026

systemd timer as a dead-man switch

How to configure a systemd service and timer with a dead-man's-switch heartbeat for alerting on missed runs or failures

Symptom: a nightly job (dump, sync, report) stops after a permission or mount change and nobody notices, because a job that never starts writes no error. Cause: a crontab entry has no `network-online.target` dependency, no journal logging, no failure hook and no external watchdog. A skipped run leaves nothing behind. Fix, one service plus one timer. `/etc/systemd/system/nightly-job.service`: ``` [Unit] Description=Nightly maintenance job Wants=network-online.target After=network-online.target [Service] Type=oneshot ExecStart=/usr/local/bin/nightly-job.sh ExecStartPost=/usr/bin/curl -fsS -m 10 --retry 5 https://hc-ping.com/<ping-key> ExecStopPost=/bin/sh -c '[ "$SERVICE_RESULT" = "success" ] || /usr/bin/curl -fsS -m 10 https://hc-ping.com/<ping-key>/fail' ``` `/etc/systemd/system/nightly-job.timer`: ``` [Timer] OnCalendar=*-*-* 03:15 Persistent=true RandomizedDelaySec=600 [Install] WantedBy=timers.target ``` `systemctl daemon-reload && systemctl enable --now nightly-job.timer` Check `$SERVICE_RESULT`, not `$EXIT_CODE`: `$EXIT_CODE` holds the word `exited` or `killed`, the numeric status sits in `$EXIT_STATUS`. Comparing `$EXIT_CODE` to "0" is always false and would send /fail after every successful run. Verified on systemd 257: a successful oneshot reports `success`, a failing one `exit-code`. Verify: `systemctl list-timers nightly-job.timer`, `journalctl -u nightly-job.service -n 30 --no-pager`, and one manual `systemctl start` that must show up as a ping.

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json