Heartbeats & cron
Make sure your scheduled jobs actually run. Instead of Moonitor reaching out to check you, your job pings Moonitor to say it ran — and if that ping doesn't arrive in time, we alert you.
What is a heartbeat monitor?
A Cron / Heartbeat monitor is a push monitor for things that run on a schedule — cron jobs, scheduled backups, queue workers and ETL jobs. Most monitors work by Moonitor reaching out to check on you. A heartbeat flips that around: your job tells Moonitor it ran by sending a request — a “ping” — to a unique URL.
If the expected ping doesn’t arrive in time, Moonitor assumes the job didn’t run and alerts you. That’s the whole point — you find out when a background job silently stops, instead of discovering it days later when a backup is missing.
Set one up
- 1
Create the monitor
In the dashboard, choose Add monitor and pick the Cron / Heartbeat type. Give it a friendly name so you recognise it later, like
Nightly DB backup. - 2
Set the expected ping period
Set the Expected ping period (seconds) — how often your job should ping. For an hourly job that’s
3600; for a daily job,86400. - 3
Save and copy the ping URL
Save the monitor. After it’s created, the monitor page shows a unique ping URL — copy the exact URL from there.
- 4
Ping from your job
Make your job send a request to that URL when it finishes successfully. That’s it — Moonitor now expects a ping on schedule.
The ping URL
Your ping URL looks like this, where TOKEN is a unique, secret value tied to your monitor:
https://your-moonitor-domain/api/heartbeat/TOKENAlways copy the exact URL from your monitor’s page rather than typing it out. Both GET and POST requests work, so use whichever is easiest from your job.
Examples
The simplest possible ping is a single curl call once your job has done its work:
curl -fsS https://app.moonitor.dev/api/heartbeat/YOUR_TOKENIn a crontab, chain the ping after your job with && so it only fires when the job succeeds:
0 * * * * /path/to/backup.sh && curl -fsS https://app.moonitor.dev/api/heartbeat/YOUR_TOKENNote
app.moonitor.dev and YOUR_TOKEN above are placeholders. Swap in the real ping URL shown on your monitor’s page.
Tip
Put the ping after your job’s work and only on success — chaining with && in a shell does exactly this. That way a failed run doesn’t falsely report healthy.
How timing works
Moonitor expects a ping within the expected period plus a short grace window (60 seconds by default). The grace window absorbs normal variation — a job that takes a little longer than usual won’t trip a false alarm.
| Event | What happens |
|---|---|
| No ping arrives in time | The monitor goes DOWN and your alert contacts are notified. |
| A ping arrives again | The monitor flips back UP and a recovery alert is sent. |
Worked example
Say your period is 3600 (hourly). Moonitor waits up to one hour plus the 60-second grace window for each ping. Miss that, and the monitor goes DOWN and your alert contacts hear about it. The next successful ping brings it back UP and sends a recovery alert.
Keep the URL secret
Heads up
Treat the ping URL like a secret. Anyone who has it can report a heartbeat for your monitor — which would hide a real outage. Don’t commit it to public repos or share it in screenshots. Pings are rate-limited to keep things sane.
Incidents and alerts
Heartbeat monitors behave like any other monitor once they’re running. Outages are recorded as incidents — grouped, timed and resolved — so you get a clear history of when a job stopped and when it recovered. Configure who gets notified under alerts & contacts.
Note
Cron / Heartbeat monitors are available on the Team and Max plans. See plans & billing for the details.