Skip to content

Cron jobs

A cron check watches scheduled tasks that cannot be reached from outside, such as backups or imports. Each task pings a private URL when it runs. When a ping is late or reports a failure, the check fails.

Enable Cron on the site and add each task with its schedule:

  • a cron expression and timezone, such as 0 3 * * * in Europe/Berlin, or
  • a simple interval in minutes.

Each task has a grace time: how long Heptapod waits past the expected time before it marks the run late. The default is five minutes. Leave room for the task’s normal runtime.

Copy the task’s ping URL from the check page. Treat it as a secret: anyone with the URL can make a missed run look healthy. If it leaks, rotate it on the check page and update the task.

The URL accepts GET and POST. Ping after the work succeeded, so a failed job cannot report success:

backup job
./backup.sh && curl --fail --silent --show-error "$HEPTAPOD_PING_URL"

Append a phase to report more:

URL Meaning
…/cron/<id> The run finished. Same as /finished.
…/cron/<id>/starting The run started.
…/cron/<id>/failed The run failed. The check fails at once.

A POST can include runtime, exit_code, memory and failure_message.

spatie/laravel-schedule-monitor can sync a Laravel schedule into Heptapod and ping it, using the Oh Dear compatible API. The settings are in the API reference.

Stop a test task and wait past its grace time. Confirm the alert, resume the task and confirm the recovery.