Linux · systemd

Systemd timer monitoring for failed and missed runs

Add Tickwatch signals to a oneshot service and detect failed or missed timer runs. Includes service and timer examples with an explicit timezone.

Free: 5 monitors, Telegram and email.

Example alert

● systemd-backup

The service reported failure. Inspect journalctl -u backup.service.

Open monitor

Demo data. Message appearance and fields depend on the channel and event type.

When you need this

An active timer does not prove backup.service produced a valid backup. A failure may be visible in journalctl long before anyone notices. Send the service result externally and track when completion is due.

How to connect

  1. 1

    Create a monitor for 0 3 * * * in Europe/Moscow. Set a grace period and runtime limit appropriate for the job.

  2. 2

    Split the example into backup.service and backup.timer in /etc/systemd/system. Replace the URL and ExecStart; use an account with the permissions required by the job.

  3. 3

    Reload the configuration, enable the timer and verify a test service result. Connect an alert channel in Tickwatch.

Ready-to-use example

Requires systemd, /bin/sh and curl at the specified path. Save two separate unit files. backup.sh must be executable and return a nonzero code on failure. The leading "-" on signal commands prevents monitoring errors from failing the job. Do not add RemainAfterExit=yes to this periodic oneshot.

backup.service + backup.timer
# /etc/systemd/system/backup.service
[Unit]
Description=Nightly backup with Tickwatch

[Service]
Type=oneshot
Environment=PING=https://ping.tickwatch.dev/YOUR_PING_KEY
TimeoutStartSec=30min
ExecStartPre=-/bin/sh -c '/usr/bin/curl -fsS --max-time 5 -X POST "$$PING/start"'
ExecStart=/usr/local/sbin/backup.sh
ExecStopPost=-/bin/sh -c 'if [ "$$SERVICE_RESULT" = success ]; then /usr/bin/curl -fsS --max-time 5 -X POST "$$PING"; else /usr/bin/curl -fsS --max-time 5 -X POST "$$PING/fail"; fi'

# /etc/systemd/system/backup.timer
[Unit]
Description=Run the nightly backup

[Timer]
OnCalendar=*-*-* 03:00:00 Europe/Moscow
Persistent=true

[Install]
WantedBy=timers.target
Run or configure
sudo systemctl daemon-reload
sudo systemctl enable --now backup.timer
systemctl list-timers backup.timer

Check before going live

  • ExecStopPost also reports startup failures. The double $$ passes SERVICE_RESULT to the shell rather than expanding it early in systemd.

  • Persistent=true catches up when the timer becomes active again; it does not prove every missed backup was produced. Validate file freshness separately.

  • Stop a test timer for one interval and verify the alert. If the host goes offline, the deadline detects the missing completion.

Common questions

Why not just ExecStartPost?

It does not cover an ExecStart failure. The example checks the result in ExecStopPost so a failed start also sends /fail.

What if the timer fires while the service is active?

The same active unit is not launched as a second concurrent instance. Monitor runtime and choose an interval appropriate for the job duration.

Verify your first run while the job still works

Create a monitor, insert your ping URL and check that signals and notifications arrive.

Systemd timer monitoring for failed and missed runs · Tickwatch