Monitor Fly.io scheduled Machines — detect failed and missed cron runs
Fly.io Machines can run on a cron schedule using the --schedule flag or
supercronic inside a long-running container. When a Machine exits non-zero, the run is
logged as failed — but no alert is sent. When Fly doesn't start a Machine for a scheduled
window (capacity, config change, region issue), nothing fires at all. Add one curl ping at
the end of a successful run to detect every silent failure in seconds.
Setup: two approaches — both with one ping
Use --schedule for simple single jobs; use supercronic for multiple schedules in one container.
Create a heartbeat monitor in LastPing
In the console, create a monitor with the same schedule as your Fly Machine (standard unix 5-field cron, UTC). Copy the ping URL.
Approach A: --schedule flag on fly machine run
Wrap your command in a shell script that pings on success and sends a /fail on error. Pass it as the Machine's command.
Approach B: supercronic inside a long-running Machine
supercronic is a container-native cron runner with stdout/stderr logging and proper signal handling. Install it in your Dockerfile, write a crontab, and run it as the container entrypoint.
Set the secret in your Fly app
Secrets are injected as environment variables at runtime and never appear in logs or image layers.
What this catches
- Non-zero exit —
/failfires; incident opens immediately. - Machine not started — scheduled window passes, no ping → incident opens on silence.
- Hung Machine —
/startarrived, success never came → overrun incident. - Recovery — next successful run closes the incident automatically.
On Render? See Render cron jobs. On Railway? See Railway. For the general pattern, see monitor cron jobs. For AI agent heartbeat monitoring via the MCP protocol, see the LastPing MCP server.
Questions people ask
-
How do I run a cron job on Fly.io?
Two main approaches: (1)
fly machine run --schedule "0 3 * * *"creates a Machine that starts on a cron schedule, runs its process once, and stops. Good for simple single-purpose jobs. (2) supercronic inside a long-running Machine — run supercronic as the container entrypoint with a crontab file. Good for multiple schedules, complex jobs, or teams already familiar with crontab syntax. -
Does Fly.io alert when a scheduled Machine fails?
No. You can view exit codes and logs via
fly logsandfly machine status, but there is no built-in notification system for cron failures or missed runs. Dead-man's-switch monitoring fills this gap — if no ping arrives in the expected window, an incident opens and you get alerted via email, Slack, Telegram, or Discord. -
What timezone does Fly.io use for scheduled Machines?
Fly.io scheduled Machines use UTC for the
--scheduleexpression. Write all times in UTC. If you're using supercronic with a crontab, addTZ=UTCor set the timezone via your Dockerfile to avoid surprises. -
Is this free?
Yes. LastPing is free and fully hosted with no monitor cap and no paid tier. See vs Healthchecks.io and vs Cronitor.
Fly.io scheduled Machines fail silently. One ping changes that.
One shell wrapper in your entrypoint. First alert in under a minute — and LastPing monitors itself the same way.