Vercel cron jobs: schedule and monitor runs

On this page

Vercel does not retry a cron job that fails, documents cron delivery as best effort, and on the Hobby plan may start a job any time within the hour. A ping from the route handler turns a run that never happened into an alert.

How can a scheduled job fail silently on Vercel Cron Jobs?

  • Vercel states that cron delivery is best effort: an occasional network error can stop a request from reaching your function, and then no function runs and no runtime log is written for that scheduled run.
  • A failed invocation is not retried. The error appears in the logs only if the function ran.
  • Cron requests do not follow redirects. A handler that answers with a 3xx status ends the run without any further request, and redirect or cached responses do not show in the logs.
  • The same scheduled run can occasionally be delivered more than once, so a job needs to cope with duplicates as well as gaps.
  • A cron job pointed at a path that does not exist produces a 404, but Vercel still executes the job and counts it.

What are the limits of Vercel Cron Jobs?

LimitWhat the documentation says
Cron jobs per project100 on every plan.
Hobby planOnce per day at most; an expression that runs more often fails the deployment. Timing is within the hour: 0 1 * * * can start any time from 1:00 to 1:59.
Pro and Enterprise plansOnce per minute at most, with per-minute precision.
Time zoneAlways UTC.
Expression rulesNo names such as MON or JAN, and the day-of-month and day-of-week fields cannot both be set; when one has a value the other must be *.
DurationThe same limits as the Vercel Function that runs the job.

How do you add a CronMissed ping to Vercel Cron Jobs?

The route handler below checks the CRON_SECRET Bearer token Vercel sends, reports the start, runs the job, and reports success or failure with the end of the error text. The ping is wrapped so that a network error on CronMissed's side can never fail the job itself.

vercel.json
{
  "crons": [
    {
      "path": "/api/cron/nightly-sync",
      "schedule": "17 4 * * *"
    }
  ]
}
app/api/cron/nightly-sync/route.ts
const PING_URL = process.env.CRONMISSED_PING_URL ?? '';

async function ping(suffix = '', body?: string): Promise<void> {
  await fetch(`${PING_URL}${suffix}`, { method: 'POST', body, signal: AbortSignal.timeout(10_000) }).catch(() => undefined);
}

export async function GET(request: Request): Promise<Response> {
  if (request.headers.get('authorization') !== `Bearer ${process.env.CRON_SECRET}`) {
    return new Response('Unauthorized', { status: 401 });
  }
  await ping('/start');
  try {
    await runJob();
    await ping();
    return Response.json({ ok: true });
  } catch (error) {
    await ping('/fail', String(error instanceof Error ? error.stack : error).slice(-100000));
    throw error;
  }
}

async function runJob(): Promise<void> {
  // the job
}

How do you schedule a cron job on Vercel?

List the route and its schedule under crons in vercel.json. Vercel calls the route on that schedule, always in UTC.

vercel.json
{
  "crons": [
    { "path": "/api/nightly-sync", "schedule": "17 4 * * *" }
  ]
}

On the Hobby plan a job can run once a day at most, while Pro and Enterprise accept up to once a minute. Check an expression with the cron expression translator before you deploy.

Which check settings fit Vercel Cron Jobs?

Use a cron check with the same expression, in UTC. On a Pro or Enterprise plan 5 minutes of grace is enough. On Hobby, Vercel can start the job any time within the hour, so set the grace to 65 minutes or more, or use a simple check with a period of one day and a grace of one hour. Add the start ping if the function can run for more than a minute.

How do you confirm the check works?

  1. In the Vercel dashboard, open the project's Cron Jobs settings and run the job from there, then check that the ping arrived.
  2. Call the route without the Authorization header and confirm it answers 401 and sends no ping.
  3. Remove the cron entry from vercel.json, redeploy, and confirm the check goes late and then down.

Sources

Questions and answers

Why does the handler ping on a failure as well?
Vercel never retries a failed run, so the quickest way to hear about an error is the /fail ping, which moves the check to down at once instead of waiting for the grace time.
Can I monitor a Vercel cron job from the outside without changing the code?
Not reliably. An uptime monitor on the route would call it, running the job, and could not tell a skipped schedule from a healthy one. The ping has to come from inside the job.
Know when this job stops

Create a check, add the ping to the job, and CronMissed alerts you the first time a run is late or reports a failure.

Start monitoring