Cron Heartbeat
Cron Heartbeat monitors your scheduled jobs by expecting periodic “heartbeat” pings. If a job fails to report in within its expected window, CheckOps alerts you before the consequences cascade.
Plan requirement: OPS and above.
HOW IT WORKS
Section titled “HOW IT WORKS”Unlike traditional monitors that actively check an endpoint, Cron Heartbeat works passively:
- Create a heartbeat monitor — Define the expected schedule (e.g., every 5 minutes, daily at 02:00)
- Get a unique endpoint — CheckOps provides a unique URL for the job to ping
- Instrument your job — Add a ping at the end of your job’s execution
- Alert on miss — If CheckOps does not receive a ping within the grace period, an alert fires
CREATING A HEARTBEAT MONITOR
Section titled “CREATING A HEARTBEAT MONITOR”| Field | Description | Example |
|---|---|---|
name |
Job description | Database backup |
schedule |
Cron expression or interval | 0 2 * * * or every 5m |
grace_period |
Time after expected execution before alerting | 300 (seconds) |
timezone |
IANA timezone for cron expression | Europe/Paris |
SUPPORTED SCHEDULE FORMATS
Section titled “SUPPORTED SCHEDULE FORMATS”Cron expressions:
0 2 * * * → Daily at 02:00*/5 * * * * → Every 5 minutes0 0 * * 1 → Every Monday at midnight0 */6 * * * → Every 6 hoursInterval shorthand:
every 1m → Every minuteevery 5m → Every 5 minutesevery 1h → Every hourevery 12h → Every 12 hoursevery 1d → Every dayINSTRUMENTING YOUR JOBS
Section titled “INSTRUMENTING YOUR JOBS”After creating a heartbeat monitor, you receive a unique endpoint:
https://api.checkops.eu/api/toolbox/cron/{monitor_id}/pingBASH / SHELL
Section titled “BASH / SHELL”#!/bin/bashpg_dump mydb > /backups/mydb_$(date +%Y%m%d).sql
# Ping CheckOps on successcurl -fsS --max-time 10 \ https://api.checkops.eu/api/toolbox/cron/abc123/pingPYTHON
Section titled “PYTHON”import requests
def run_job(): # ... your job logic ... pass
if __name__ == "__main__": run_job() requests.get("https://api.checkops.eu/api/toolbox/cron/abc123/ping", timeout=10)KUBERNETES CRONJOB
Section titled “KUBERNETES CRONJOB”apiVersion: batch/v1kind: CronJobmetadata: name: db-backupspec: schedule: "0 2 * * *" jobTemplate: spec: template: spec: containers: - name: backup image: postgres:16 command: - /bin/sh - -c - | pg_dump $DATABASE_URL > /backups/dump.sql && \ curl -fsS https://api.checkops.eu/api/toolbox/cron/abc123/ping restartPolicy: OnFailurePING STATUS REPORTING
Section titled “PING STATUS REPORTING”You can report the job outcome in the ping:
# Report successcurl https://api.checkops.eu/api/toolbox/cron/abc123/ping?status=ok
# Report failure (still counts as "alive" but logs the failure)curl https://api.checkops.eu/api/toolbox/cron/abc123/ping?status=fail
# Report with durationcurl https://api.checkops.eu/api/toolbox/cron/abc123/ping?status=ok&duration=42sALERT BEHAVIOR
Section titled “ALERT BEHAVIOR”| Scenario | Result |
|---|---|
| Ping received on time | Status: UP |
| Ping received late (within grace) | Status: UP (with warning) |
| No ping within schedule + grace | Status: DOWN, alert fires |
Ping with status=fail |
Status: DEGRADED, alert fires |