Vivere

systemd timers

Report a systemd service run with ExecStartPre / ExecStartPost.

A systemd timer runs a service; add the ping to the service unit.

# /etc/systemd/system/backup.service
[Unit]
Description=Nightly backup

[Service]
Type=oneshot
ExecStartPre=/usr/bin/curl -fsS -m 10 -o /dev/null https://vivere.dev/p/<monitor-id>/start
ExecStart=/opt/backup.sh
ExecStopPost=/usr/bin/curl -fsS -m 10 -o /dev/null https://vivere.dev/p/<monitor-id>/${EXIT_STATUS}

ExecStopPost runs whether the service succeeded or failed, and $EXIT_STATUS carries the exit code, so failures are reported with the right code. ExecStartPre with a leading - (ExecStartPre=-/usr/bin/curl …) would ignore ping failures if you prefer never to block the job on the network.

Or wrap it: ExecStart=/usr/local/bin/vivere run --url https://vivere.dev/p/<monitor-id> -- /opt/backup.sh.

# /etc/systemd/system/backup.timer
[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true

[Install]
WantedBy=timers.target

Give the monitor the cron expression 0 2 * * * in the machine's timezone.