Know when a cron script did not run: one curl line
Add one curl to the end of your crontab line, with the job's schedule in the URL: curl -fsS "http://127.0.0.1:8000/ping/backup?schedule=0+2+*+*+*". Buggregator then knows when the job should run. If nothing comes by then, it marks the run as missed. Ping at the start too, and a run that never finishes shows up as hung.
Steps
1. Start Buggregator with a database file
The default database lives in memory, so jobs and runs are gone after a restart. Keep them in a file:
buggregator -db buggregator.dbIn Docker, keep the file in a volume:
docker run --pull always \
-p 127.0.0.1:8000:8000 \
-v buggregator-data:/data \
ghcr.io/buggregator/server:latest -db /data/buggregator.db2. Add the curl to the crontab line
The first ping creates the job. No setup in Buggregator. A + in the schedule is a space.
0 2 * * * /opt/backup.sh && curl -fsS "http://127.0.0.1:8000/ping/backup?schedule=0+2+*+*+*"If the script fails, no ping comes, and the run counts as missed.
3. Report start, failure and output
For hung runs, failures and the job's output, wrap the script. A POST body is kept as the run's output, the last 10 KB.
B=http://127.0.0.1:8000
curl -fsS "$B/ping/backup/start?schedule=0+2+*+*+*&tz=Europe/Berlin"
if ./backup.sh > out.log 2>&1; then
curl -fsS -X POST --data-binary @out.log "$B/ping/backup"
else
curl -fsS -X POST --data-binary @out.log "$B/ping/backup/fail"
fiMore options go in the query: margin (minutes a run may be late, default 1), max_runtime (minutes a run may take, default 30), tz (default UTC) and project.
4. Open Crons
Open http://127.0.0.1:8000, then Sentry → Crons. Each job shows its status, schedule, last and next run, and a strip of the last 20 runs. Jobs that failed, hung or missed a run come first, under Needs attention. Open a job for its run history and the output each run sent.
Why it works
A ping tells Buggregator «started», «finished» or «failed». With the schedule it knows when the next run is due. Every 30 seconds it checks: a due run with no ping after the margin becomes missed, and a started run that takes longer than max_runtime becomes timeout. Buggregator shows this in the UI; it sends no alerts.
Docs: docs.buggregator.dev/config/crons.html#ping-url
Requires Buggregator v2.13.0+
Related tips
- Crons
Know when a Laravel scheduled task did not run
Add ->sentryMonitor() to a scheduled task and point the Sentry DSN at Buggregator. Each run shows up, and missed or hung runs are marked.
- Crons
Python cron jobs with Sentry's @monitor, locally
Point sentry_sdk at Buggregator and keep your @monitor decorator. Every run shows up, and Buggregator marks missed and hung runs. No Sentry account.
- Logs
Laravel logs from web, queue and cron in one live view
Add a socket channel to config/logging.php and set LOG_CHANNEL=socket. Laravel logs from requests, queue workers and cron jobs appear live in Buggregator.
Checked on with Buggregator v2.13.0