Cron Monitoring
Monitor cron jobs, scheduled tasks, and heartbeats. Know when jobs fail, run late, or disappear. Dead man's switch included.
How Cron Monitoring Works
Unsparing uses ping URLs for cron monitoring. Your cron job pings Unsparing when it starts (or finishes). If Unsparing doesn't receive a ping within the expected window, it triggers an alert.
This is the dead man's switch pattern: silence is the signal.
Adding a Cron Task
- Navigate to Cron → Tasks and click Add Task
- Configure the task:
| Field | Description |
|---|---|
| Name | A human-readable name (e.g., "Backup Database") |
| Schedule | Cron expression or human-readable schedule |
| Grace Period | How long to wait after the expected time before alerting |
| Timezone | The timezone for the schedule |
- Unsparing generates a unique ping URL:
https://api.unsparing.dev/api/v1/ping/{task_id} - Add the ping to your cron job
Integration Patterns
Crontab
# Ping before the job
0 2 * * * curl -s https://api.unsparing.dev/api/v1/ping/YOUR_PING_ID >> /dev/null 2>&1 && /usr/local/bin/backup.shSystemd Timer
[Service]
ExecStart=/usr/local/bin/backup.sh
ExecPostStart=/usr/bin/curl -s https://api.unsparing.dev/api/v1/ping/YOUR_PING_IDAny Script
#!/bin/bash
# At the start of your job
curl -s https://api.unsparing.dev/api/v1/ping/YOUR_PING_ID
# Your job logic here
/usr/local/bin/your-script.sh
# Optional: ping again to mark completion
curl -s https://api.unsparing.dev/api/v1/ping/YOUR_PING_ID/finishKubernetes CronJob
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: backup:latest
command: ["/bin/sh", "-c"]
args:
- |
curl -s https://api.unsparing.dev/api/v1/ping/YOUR_PING_ID
/usr/local/bin/backup.shAlert Types
| Alert | Trigger |
|---|---|
| Job didn't run | No ping received within schedule + grace period |
| Job ran late | Ping received after the expected window |
| Job ran outside schedule | Ping received outside the cron schedule |
| Job completed | Ping with /finish endpoint received |
Grace Periods
Grace periods prevent false alerts. If your job usually takes 5 minutes, set a grace period of 10 minutes. Unsparing will only alert if no ping is received after the grace period expires.
Recommended grace periods:
| Job Type | Grace Period |
|---|---|
| Quick tasks (< 1 min) | 5 minutes |
| Medium tasks (1-10 min) | 15 minutes |
| Long tasks (10-60 min) | 30 minutes |
| Batch jobs (1+ hour) | 2x the expected runtime |
API Endpoints
List Cron Tasks
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.unsparing.dev/api/v1/cron/tasksCreate a Cron Task
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Backup Database", "schedule": "0 2 * * *", "grace_period": 300}' \
https://api.unsparing.dev/api/v1/cron/tasksPing a Cron Task
curl https://api.unsparing.dev/api/v1/ping/YOUR_PING_IDPlan Limits
| Plan | Cron Tasks |
|---|---|
| Free | 3 |
| Homelabber | Unlimited |
| Teams | Unlimited |
| Agency | Unlimited |