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.
Define the tasks
Section titled “Define the tasks”Enable Cron on the site and add each task with its schedule:
- a cron expression and timezone, such as
0 3 * * *inEurope/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.
Send the pings
Section titled “Send the pings”The URL accepts GET and POST. Ping after the work succeeded, so a failed job
cannot report success:
./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.
Laravel schedules
Section titled “Laravel schedules”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.
Test a missed run
Section titled “Test a missed run”Stop a test task and wait past its grace time. Confirm the alert, resume the task and confirm the recovery.