Unsparing Docs

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

  1. Navigate to Cron → Tasks and click Add Task
  2. Configure the task:
FieldDescription
NameA human-readable name (e.g., "Backup Database")
ScheduleCron expression or human-readable schedule
Grace PeriodHow long to wait after the expected time before alerting
TimezoneThe timezone for the schedule
  1. Unsparing generates a unique ping URL: https://api.unsparing.dev/api/v1/ping/{task_id}
  2. 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.sh

Systemd Timer

[Service]
ExecStart=/usr/local/bin/backup.sh
ExecPostStart=/usr/bin/curl -s https://api.unsparing.dev/api/v1/ping/YOUR_PING_ID

Any 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/finish

Kubernetes 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.sh

Alert Types

AlertTrigger
Job didn't runNo ping received within schedule + grace period
Job ran latePing received after the expected window
Job ran outside schedulePing received outside the cron schedule
Job completedPing 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 TypeGrace 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/tasks

Create 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/tasks

Ping a Cron Task

curl https://api.unsparing.dev/api/v1/ping/YOUR_PING_ID

Plan Limits

PlanCron Tasks
Free3
HomelabberUnlimited
TeamsUnlimited
AgencyUnlimited

Alerts & Notifications · API Reference

On this page