StoicBuilder

HandbookII the ForumBackground jobs and cron

IIthe Forum, The shape of an app

Background jobs and cron

1 min readUpdated 28 November

In plain words

A background job is work your app does after the visitor has moved on, and cron is a timer that starts jobs on a schedule, such as nightly at 2am.

Where you see it

A crons section in vercel.json, a scheduled function in Supabase, or a dashboard such as Inngest or Trigger.dev. QuickBite's Monday-morning receipt summary goes out because a cron job sends it, not because anyone clicked anything.

vercel.jsonconfig
{ "crons": [ { "path": "/api/cron/weekly-receipts", "schedule": "0 8 * * 1" } ]}
Every Monday at 08:00 UTC, Vercel calls that route. The five fields are minute, hour, day of month, month and weekday.

What goes wrong

  1. Doing slow work while the visitor waits

    Generating a PDF or emailing 500 members inside one request makes the page hang, and hosts cut requests off after a time limit. Hand the work to a job and answer the visitor at once.

  2. Forgetting the schedule is in UTC

    Vercel reads cron times in UTC, so 0 9 * * * is 9am in London only in winter, and 4 or 5am in New York. Pick the hour on purpose.

  3. Leaving the cron route open

    A cron job is a normal web address. Without a secret check, anyone who finds /api/cron/weekly-receipts can trigger 5,000 emails.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Move any slow work in this request, such as emails, PDFs or image processing, into a background job and reply to the user straight away. For scheduled jobs, state the time in both UTC and my local time, and protect the job's route with a secret.

Quick check

Sign in to earn +10 XP for it

Guildhall's "invite all members" button spins for a minute, then fails with a timeout, though some invites went out. Best fix?

Got a prompt that touches background jobs and cron?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.