Monitor Railway cron services — detect failed and missed scheduled jobs
Railway lets you set a Cron Schedule on any service. On that schedule, Railway
starts your service container, runs the start command, and stops it when it exits. If the
command exits non-zero, the run is logged as failed — but no notification is sent unless
you've opted into deployment alerts. Add one curl ping at the end of a
successful run to know within minutes when any run fails, hangs, or is never started.
Setup: one change to the start command, about a minute
Append a curl ping in your service's Start Command field. Works for any language — it's just shell.
Create a heartbeat monitor in LastPing
In the console, create a monitor and set the schedule to match your Railway cron schedule (5-field unix cron, UTC). Set a grace window of 15–60 minutes depending on how long the job runs. Copy the ping URL.
Update the Start Command in Railway
In your service's Settings → Deploy → Start Command, append && curl … so the ping only fires on a zero exit. Store the monitor ID as a Railway environment variable (LASTPING_MONITOR_ID).
Optional: fail-fast ping for immediate alerts
Add || curl …/fail to be alerted the moment the job fails, without waiting out the grace window:
Add the environment variable in Railway
In your service's Variables tab, add LASTPING_MONITOR_ID with your monitor UUID as the value. Railway injects it at runtime; it is not stored in your image or committed to git.
Set the Cron Schedule in Railway
In Settings → Deploy → Cron Schedule, enter your schedule in 5-field unix cron (UTC). Railway runs the service on this schedule and stops it when the process exits.
What this catches
- Non-zero exit — ping skipped; no ping in grace window → incident opens.
- Silent logical failure — add validation inside your job; only ping on confirmed success.
- Railway doesn't start the service — scheduled window passes, no ping → incident opens.
- Recovery — next successful run closes the incident automatically.
On Render? See Render cron jobs. On Fly.io? See Fly.io scheduled Machines. For the concept, see silent failure of scheduled jobs.
Questions people ask
-
How do I create a cron job in Railway?
Create a service from a repo or Docker image. In Settings → Deploy, enter a Cron Schedule (5-field unix cron, UTC) and a Start Command. Railway starts the container on the schedule, runs the command, and stops the container when it exits. The service is not long-running — it starts fresh for each run.
-
Does Railway alert when a cron service fails?
Not by default. Railway shows failed deployments in the activity feed. You can enable deployment failure notifications in your Railway notification settings, but missed runs (when Railway doesn't start the container) produce nothing. Dead-man's-switch monitoring detects both: if no ping arrives in the grace window, an incident opens and you get alerted.
-
What timezone does Railway use for cron schedules?
Railway cron schedules use UTC. There is no per-service timezone setting. Convert your desired local time to UTC when setting the schedule.
-
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.
Railway cron services fail quietly. One ping changes that.
Append it to your start command. First alert in under a minute — and LastPing monitors itself the same way.