Telemetry
Background jobs SQL recipe

Detect Missed Cron Schedules

Compare consecutive cron-run events with each schedule interval to find late or missing executions.

Intermediatecron_runsReviewed 2026-07-28Tested with Apache DataFusion 45.2.0

Question answered

Which scheduled jobs ran later than their documented interval?

A cron process that never starts cannot emit a failure. Comparing the gap between observed runs with the expected interval detects silence that ordinary error-rate queries miss.

Event contract

Fields the query expects

FieldTypeWhy it exists
timestamp_utcTimestampObserved cron-run start time.
schedule_nameUtf8Stable scheduled-workflow name.
environmentUtf8Deployment environment.
expected_interval_minutesFloat64Documented minutes between starts.
DataFusion SQL

Copy the query

sql
WITH ordered_runs AS (
  SELECT
    schedule_name,
    environment,
    timestamp_utc AS run_at,
    expected_interval_minutes,
    LAG(timestamp_utc) OVER (
      PARTITION BY schedule_name, environment
      ORDER BY timestamp_utc
    ) AS previous_run_at
  FROM cron_runs
  WHERE timestamp_utc >= now() - INTERVAL '7 days'
)
SELECT
  schedule_name,
  environment,
  previous_run_at,
  run_at,
  expected_interval_minutes,
  date_part('second', run_at - previous_run_at) / 60.0 AS observed_gap_minutes
FROM ordered_runs
WHERE previous_run_at IS NOT NULL
  AND date_part('second', run_at - previous_run_at) / 60.0
    > expected_interval_minutes * 1.5
ORDER BY observed_gap_minutes DESC;

This read-only query is planned and executed against an empty typed table with Apache DataFusion 45.2.0. The deterministic sample output is synthetic and reviewed separately; validate field types, thresholds, and business definitions against your own data. Read the testing methodology.

Query result

Observed schedule gaps

The billing sync missed two expected starts, while the daily expiration workflow skipped one day.

schedule_nameenvironmentprevious_run_atrun_atexpected_interval_minutesobserved_gap_minutes
hourly_billing_syncproduction2026-07-27 07:002026-07-27 10:0060180
daily_trial_expirationproduction2026-07-25 02:002026-07-27 02:001,4402,880

Synthetic example output. Run the query against your own event schema and thresholds before using it for operational decisions.

How the SQL works

  1. 1LAG retrieves the previous observed start for each schedule and environment.
  2. 2The timestamp difference becomes an observed gap that can be compared with each job's own interval.
  3. 3A 1.5 multiplier allows normal scheduling jitter without hiding a genuinely missed run.

Edge cases to decide

  • This historical query detects a gap only after the next run arrives; pair it with a current missing-heartbeat alert.
  • Planned maintenance and disabled schedules should emit explicit state changes.
  • Daylight-saving transitions require UTC schedules or timezone-aware expectations.

Recommended dashboard

  • Table: missed starts with previous and next run
  • Trend: schedule-gap minutes by job
  • Stat: production schedules currently overdue

Alert guidance

For real-time detection, alert when the latest run is older than the expected interval plus documented jitter.

Read alert setup

Put the recipe to work

Related instrumentation and guides

Continue the analysis

Run it on real events

Create a table, adapt the fields, and save the result

Start free, send structured events, and use the query result as a chart, shared dashboard widget, or alert input.

Get an API key