Heartbeat Monitoring

Monitor Linux Cron Jobs with Alert24 Heartbeat Checks

Set up Alert24 heartbeat monitoring for Linux cron jobs. Get alerted when a cron job stops running or fails silently — one curl command added to your crontab.

Cron jobs are silent by default — if one stops running, nothing alerts you. Alert24 heartbeat checks fix this: your cron job pings Alert24 after it completes, and if Alert24 doesn't hear from it within the expected interval, it fires an incident.

Before you start

  1. In Alert24, go to Monitoring → Add check → Heartbeat
  2. Give it a name (e.g., "Daily DB backup")
  3. Set the Expected interval to match how often your cron job runs (e.g., 86400 seconds for daily)
  4. Set a Grace period (e.g., 300 seconds) to allow for runtime variance
  5. Save — Alert24 gives you a heartbeat URL like:
    https://app.alert24.net/api/hb/YOUR_TOKEN
    

Add the ping to your cron job

Open your crontab (crontab -e) and append the curl ping to your existing job using &&:

# Run daily backup and ping Alert24 on success
0 2 * * * /home/ubuntu/scripts/backup.sh && curl -fsS --retry 3 https://app.alert24.net/api/hb/YOUR_TOKEN

The && means the ping only fires if the backup script exits with code 0. If the script fails, no ping — Alert24 fires an incident after the grace period.

For jobs that run frequently

For jobs running every few minutes:

*/5 * * * * /usr/local/bin/sync-data.sh && curl -fsS --retry 3 https://app.alert24.net/api/hb/YOUR_TOKEN

Set the Alert24 heartbeat interval to 300 seconds (5 minutes) and grace period to 60 seconds.

Handling slow jobs

If your job sometimes takes longer than the interval, wrap the curl call at the end of the script rather than in crontab:

#!/bin/bash
# backup.sh

set -euo pipefail

# ... your backup logic ...
pg_dump mydb | gzip > /backups/mydb-$(date +%Y%m%d).sql.gz

# Ping Alert24 only on success
curl -fsS --retry 3 "https://app.alert24.net/api/hb/YOUR_TOKEN"

Silent curl flags

  • -f — fail silently on HTTP errors (don't print error pages)
  • -s — silent mode (suppress progress meter)
  • -S — show error even in silent mode
  • --retry 3 — retry up to 3 times on transient network failures

Tips

  • Separate checks per job: Create one Alert24 heartbeat check per cron job. This way you know exactly which job failed, not just "something broke".
  • Using wget instead of curl: wget -q -O /dev/null https://app.alert24.net/api/hb/YOUR_TOKEN works identically.
  • Root crontab vs user crontab: If the job runs in root's crontab, make sure curl is in root's PATH (/usr/bin/curl or use the full path to be safe).
  • Redirecting output: Silence the curl output completely with > /dev/null 2>&1 if your cron setup emails stdout.