Guide

How to monitor cron jobs

Cron jobs fail silently. The server reboots and cron doesn't restart. The disk fills up and the job exits with an error nobody sees. The job runs but takes 4 hours instead of 5 minutes. Without monitoring, you find out when a customer asks why their report is missing.

HOW IT WORKS

Heartbeat monitoring

Instead of Larm checking your service, your service pings Larm. Create a heartbeat monitor with an expected interval (how often the job should run) and Larm gives you a unique URL. Add a curl to the end of your cron job. If the ping stops arriving, Larm alerts your team.

STEP 1

Create a heartbeat monitor

In Larm, create a new monitor and select "Heartbeat" as the type. Set the expected interval to match your cron schedule. A job that runs every hour gets a 1-hour interval. Set consecutive misses to 2 or 3 if you want to tolerate an occasional skip before alerting.

STEP 2

Add the ping to your cron job

Copy the heartbeat URL from the monitor and add a curl to the end of your cron command:

0 * * * * /path/to/your/job.sh && curl -fsS --retry 3 https://app.larm.dev/api/heartbeat/YOUR_TOKEN

The && ensures the ping only fires if the job succeeds. If the job fails, no ping is sent, and Larm alerts you on the next missed interval.

WORKS WITH EVERYTHING

Not just cron

Heartbeat monitoring works for anything that runs on a schedule: Kubernetes CronJobs, Oban workers, Sidekiq recurring jobs, GitHub Actions scheduled workflows, AWS Lambda scheduled events, Windows Task Scheduler. Anything that can make an HTTP request can ping Larm.

Need help building a cron expression? Try our cron expression generator.

Know when your cron jobs stop running.

Heartbeat monitoring on every plan. Alert to Slack, PagerDuty, or any of 14 integrations. Free to start.

Sign Up Free