Larm·April 26, 2026·Updated November 8, 2026monitoringcronhow-it-works

How to monitor cron jobs and background workers

A cron job that stops running produces no error, so normal checks can't see it. How heartbeat monitoring works, with examples for shell scripts, Oban, Sidekiq and systemd timers.

When a web server goes down, requests fail and an HTTP check catches it. When a cron job stops running, nothing fails. There's no error and no failed request, and there's nothing in the logs because nothing ran. The only sign is that the work didn't get done, and that can go unnoticed for a long time.

Why scheduled jobs stop running

Often the job itself is fine, and something around it changed.

The schedule is gone. A server was rebuilt or replaced, and a crontab that was edited by hand on the old machine didn't come along.

The environment changed. After a deploy, the job runs without an environment variable it needs, or a path or dependency it relies on moved.

The job runs and fails. It starts, hits an error, and exits with a non-zero code. Cron ran the command, and that's all cron checks.

The job overlaps itself. It takes longer than the time between runs, so the next run starts before the last one finishes. Depending on the job, that means duplicate work or lock contention.

Kubernetes stops it. A CronJob's pod gets evicted, the job hits its activeDeadlineSeconds, or concurrencyPolicy: Forbid skips a run because the previous one is still going. Kubernetes records these, but nothing alerts you by default.

Heartbeat monitoring

You can't watch a job from the outside when the problem is that it didn't run. So you turn it around: the job reports in when it finishes, and the monitor alerts you when the reports stop.

  1. Create a heartbeat monitor with the job's expected interval, for example every hour.
  2. The monitor gives you a unique URL.
  3. At the end of the job, request that URL.
  4. If no request arrives in time, the monitor goes down and alerts you.

The monitor doesn't need to know what the job does. It only knows how often to expect a ping. The cron job monitoring guide walks through setting one up in Larm.

Adding the ping

Put the ping at the end, after the work is done. If the job fails halfway through, it shouldn't report in.

A shell script:

#!/bin/bash
set -e
 
python /app/generate_report.py
rsync -a /data/reports/ /backup/reports/
 
curl -fsS --retry 3 https://app.larm.dev/api/heartbeat/your-token

set -e stops the script at the first failing command, so curl only runs if everything before it succeeded. -f makes curl exit with an error on an HTTP error response, -sS hides the progress output but still prints errors, and --retry 3 retries on transient failures.

An Oban worker in Elixir:

defmodule MyApp.Workers.NightlyReport do
  use Oban.Worker, queue: :reports
 
  @heartbeat_url "https://app.larm.dev/api/heartbeat/your-token"
 
  @impl Oban.Worker
  def perform(_job) do
    with :ok <- generate_report(),
         :ok <- send_notifications() do
      Req.get!(@heartbeat_url)
      :ok
    end
  end
end

A Sidekiq job in Ruby:

class NightlyReportJob
  include Sidekiq::Job
 
  HEARTBEAT_URL = "https://app.larm.dev/api/heartbeat/your-token"
 
  def perform
    generate_report
    send_notifications
    Net::HTTP.get(URI(HEARTBEAT_URL))
  end
end

A systemd timer: add ExecStartPost to the service unit the timer starts. systemd only runs ExecStartPost after ExecStart has succeeded.

[Service]
Type=oneshot
ExecStart=/app/generate_report.sh
ExecStartPost=/usr/bin/curl -fsS https://app.larm.dev/api/heartbeat/your-token

Choosing the interval

Set the expected interval to how often the job runs. An hourly job gets one hour.

Larm already allows for some lateness. A heartbeat monitor goes down when no ping has arrived for 1.2 times the expected interval, multiplied by the number of consecutive misses you allow. The default is 2 misses, so an hourly job alerts after about 2 hours and 24 minutes without a ping. Set misses to 1 if you want to know after 72 minutes.

The expected interval can be anything from 10 seconds to 24 hours, with a lower minimum on paid plans. For a job that runs less often than daily, use a 24-hour interval and raise the misses: with 7 misses, a weekly job alerts after about 8 and a half days without a ping.

The heartbeat endpoint

The ping URL is https://app.larm.dev/api/heartbeat/<token>, and you get the token when you create the monitor. It accepts any HTTP method, ignores the body, and needs no authentication or SDK. It always responds with 200 and {"status":"ok"}, even for an unknown token, so the response can't be used to guess valid tokens.

When the pings stop, Larm alerts you through the monitor's alert channels, the same as any other monitor going down. See the heartbeat API reference for details.

Larm's free plan includes 15 monitors, and heartbeat monitors count toward that like any other.

Start monitoring in minutes.

Free plan. 15 monitors. Multi-probe voting. No credit card.

Sign Up Free