← All guides

How to know when a cron job silently stops running

Why a failed backup or nightly report usually goes unnoticed for days, how heartbeat monitoring turns a scheduled job into something you can watch, and what to do with the alert when it fires.

Published: Updated: 5 min read

Cron is reliable right up to the moment it isn't. A server reboots and the crontab was never restored, a backup script exits with an error nobody reads, a report job that used to take four minutes now takes forty because the table grew. None of these show up in a web dashboard, because nothing is down in the usual sense: the job simply did not happen.

The fix is a pattern operations teams have used for years under names like dead man's switch or heartbeat: the job announces that it finished, and a separate service raises an alarm when the announcement does not arrive. This guide shows how to set that up, how to choose the timing, and how to make the alert useful rather than noisy.

Why uptime checks miss scheduled jobs

A normal monitor asks a question on a schedule: is this URL answering, is this port open, is this DNS record correct. A scheduled job has nothing to ask. There is no process listening between runs, and a job that never starts leaves no trace at all. Looking at log files only works if someone remembers to look.

A heartbeat inverts the direction. Instead of the monitor calling the job, the job calls the monitor. If the call is late, the job is late; if the call never comes, the job did not run. In DevKit a heartbeat is a URL you give to a job: if the job does not call it in time, fails or runs too long, you hear about it, together with its exit code and log.

Set up the heartbeat

  1. Open a cloud workspace. Heartbeats and the other cloud monitors work from the first launch, before you sign in; sign in with an email code or with Apple to keep them on every device. SSH and the network tools need no account. Every workspace starts on the Free plan.
  2. Create a heartbeat and copy its URL. Give it the name of the job as you would say it to a colleague, for example "nightly database backup", so the alert reads well later. The URL is shown only once, so store it with the job; a new one can be issued later.
  3. Set the expected interval and a grace period. A job that runs every night at 02:00 should be expected every 24 hours with enough slack for a slow night. Too tight and you get alerts for normal variance; too loose and you learn about the failure a day late.
  4. Call the URL at the end of the job, not the start. The URL is https://devkit-api.odbs.tech/v1/heartbeats/ followed by the heartbeat's own token. With the job wrapped in a shell script, run your-job && curl -fsS --retry 3 "$HEARTBEAT_URL" so the request is only sent when the job itself exits successfully. A job that starts and crashes should look exactly like a job that never ran.
  5. Send the exit code and the log, if you want them. Run your-job > job.log 2>&1; curl -fsS --retry 3 --data-binary @job.log "$HEARTBEAT_URL/$?" instead: an exit code of 0 counts as success and any other code as a failure, which DevKit reports at once, and the first 10 KB of the output is kept as the run's log. To hear about a run that takes too long, also call curl -fsS "$HEARTBEAT_URL/start" when the job begins and set Longest run on the heartbeat.
  6. Run it once by hand. Trigger the job manually and confirm the heartbeat arrives before trusting the schedule. Until a check has run, DevKit shows the state as no data, never as up.

Decide where the alert goes

A heartbeat that fires into an inbox nobody opens is no better than the log file you were not reading. DevKit delivers alerts by email, webhook, Slack, Discord and Telegram, as well as to the in-app inbox; email and the inbox are included on Free, the chat and webhook channels come with Pro.

Pick the channel the person on duty actually watches. For a job that only matters during business hours, email is enough. For a backup or a billing run, send it to the same channel as your outage alerts, and let the reminder repeat while the problem lasts so one missed notification does not become a missed week.

  • Use a maintenance window for planned downtime such as a database migration. Checks keep running, but nothing in the window raises an alert.
  • Keep one heartbeat per job. A shared URL for three scripts tells you that something is wrong, never which one.
  • If the job legitimately runs at different intervals on weekdays and weekends, set the interval to the longer gap and accept slightly later alerts on weekdays.

When the alert fires

Read the reason before touching anything. A late heartbeat and a failed one point at different problems: late usually means the job is slow or the schedule drifted, failed means the job ran and the script returned an error. The exit code and the log tell you which, and a job that ran too long is a third, quieter signal that something upstream is growing.

Then connect. If the server is one you already trust, DevKit's server summary over SSH shows uptime, load, memory, disks, failed services and Docker containers in one tap, which is usually enough to tell a full disk from a crashed daemon. Opening the terminal from the same app saves switching to a laptop in the middle of the night. SSH passwords and keys stay in the device's Keychain and never reach DevKit's servers.