---
title: "Cron jobs"
description: "Scheduled tasks ping Heptapod; late, missed or failed runs alert."
---

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

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.

## Send the pings

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

backup job

```bash
./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`.

Danger

Do not send the success ping before the job runs, or from a cleanup handler that runs on every exit. That reports activity, not successful work.

## Laravel schedules

[spatie/laravel-schedule-monitor](https://github.com/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](/docs/reference/api/#compatibility).

## Test a missed run

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