Skip to main content

Cron job not running? See missed, failed and hung runs

"Not running" can mean three different things: the job never started, it started and failed, or it started and never finished. Wrap the job in pings to Buggregator: one at the start, one at the end with the job's output. Buggregator then marks each run as finished, failed, missed or timed out, and keeps the last 10 KB of what the job printed. You see which of the three happened, and why.

Steps

1. Start Buggregator with a database file

The default database lives in memory, so runs are gone after a restart.

bash
buggregator -db buggregator.db

2. Wrap the job in a small script

Save this as cron-run.sh and make it executable. It pings the start, runs your command, and sends its output as a success or a failure.

bash
#!/bin/sh
# Usage: cron-run.sh <job-name> "<schedule>" <command> [args...]
B=http://127.0.0.1:8000
job=$1; schedule=$2; shift 2
log=$(mktemp)

curl -fsS -G "$B/ping/$job/start" --data-urlencode "schedule=$schedule" --data-urlencode "tz=UTC" > /dev/null
if "$@" > "$log" 2>&1; then
  curl -fsS -X POST --data-binary @"$log" "$B/ping/$job" > /dev/null
else
  curl -fsS -X POST --data-binary @"$log" "$B/ping/$job/fail" > /dev/null
fi
rm -f "$log"

3. Use it in the crontab

Give the same schedule as the crontab line. Set tz in the script to the time zone your cron daemon uses; Buggregator reads the schedule in UTC by default.

bash
0 2 * * * /opt/cron-run.sh backup "0 2 * * *" /opt/backup.sh

4. Read the status

Open http://127.0.0.1:8000, then Sentry → Crons. Jobs that failed, hung or missed a run come first, under Needs attention. Open a job for its runs and the output each run sent.

Status What it means Where to look
missed the run was due and no ping came the crontab line, the cron daemon, the schedule and time zone
Failed the command exited with an error the run's output
Timed out the run started and did not finish within max_runtime a lock, a stuck network call, a too small limit
ok the run finished fine nothing

A run counts as missed when nothing comes within the margin after it was due: 1 minute by default. A run counts as hung after 30 minutes by default. Change both in the start ping with margin and max_runtime, in whole minutes.

Why it works

The start ping carries the schedule, so Buggregator knows when the next run is due. Every 30 seconds it checks each job. A due run with no ping becomes missed, and a started run older than max_runtime becomes timeout. A POST body is kept as the run's output, the last 10 KB. Buggregator shows this in the UI and sends no alerts.

Checked on with Buggregator v2.13.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces

Rather not run a script? Download the file yourself

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you