Tutorial

How to Monitor Cron Jobs with Heartbeat Monitoring

Cron jobs fail silently. Here's how to set up heartbeat monitoring so you know the instant a scheduled task stops running — with examples in bash, Python, and Node.js.

March 10, 2026
4 min read
#guide#heartbeat#cron

The problem with cron jobs

Cron jobs fail silently. The process exits with a non-zero code, nothing happens, and you don't find out until a customer complains that their weekly report is missing or their data hasn't been updated in three days.

Uptime monitoring checks if your servers are reachable. Heartbeat monitoring checks if your cron jobs are running. They're different problems.

How heartbeat monitoring works

The concept is simple: your cron job pings a unique URL at the end of each successful run. If the URL hasn't been pinged within the expected interval plus a grace period, you get alerted. Sentro creates an incident and dispatches notifications to your configured channels.

Setting up a heartbeat monitor in Sentro

  1. Go to Heartbeats in the Sentro dashboard
  2. Click New Heartbeat
  3. Set the expected interval (e.g. 1 hour for an hourly job)
  4. Set a grace period (e.g. 5 minutes to account for variable run times)
  5. Copy the ping URL: https://api.sentro.dev/ping/your-unique-slug

Adding the ping to your jobs

Bash / Shell:

#!/bin/bash
set -e
python sync_data.py
# Signal success to Sentro — only runs if the above succeeded
curl -fsS --retry 3 "https://api.sentro.dev/ping/your-unique-slug" > /dev/null

Python:

import urllib.request

def run_job():
    sync_data()
    process_queue()

if __name__ == "__main__":
    run_job()
    # Ping Sentro on success
    urllib.request.urlopen("https://api.sentro.dev/ping/your-unique-slug")

Node.js:

import { syncData } from './sync';

await syncData();

// Signal success — fire and forget
fetch('https://api.sentro.dev/ping/your-unique-slug').catch(() => {});

What happens when it fails

If Sentro doesn't receive a ping within your interval + grace period, it marks the heartbeat monitor as DOWN, creates an incident, and sends alerts to your configured channels — Slack, email, PagerDuty, wherever you need them.

Best practices

  • Only ping on success — Put the ping call after your job logic, not at the start. If the job fails early, the ping never fires, which is what you want.
  • Set the grace period generously — If your job usually takes 45 seconds but can occasionally take 3 minutes, set a 5-minute grace period. False alarms from slow jobs are annoying.
  • Monitor the monitoring — For critical jobs, also add an HTTP monitor to check that your cron scheduler (e.g. cron service endpoint) is running.

Heartbeat monitoring is available on all Sentro plans. The free plan includes 1 heartbeat monitor. Starter includes 5, Pro includes 20, Max includes 100.

Tagged:#guide#heartbeat#cron

Get started

Start monitoring for free

5 monitors, 5-minute intervals, email + Slack alerts. No credit card required.

How to Monitor Cron Jobs with Heartbeat Monitoring — Sentro Blog | Sentro