1. Courses
  2. AI Engineering
  3. Run and Grow Your Site
  4. Stop 5

30 minBeginner

Reports and alerts that run themselves

You shouldn't have to open five dashboards to know how your site did yesterday. This lesson sets up a nightly report e-mail for Mangrove Kitchen, sent by a scheduled job, through a route that only answers when it gets the right secret.

By the end you can

  • Explain what a scheduled job is and choose between Vercel Cron and Supabase pg_cron
  • Protect a report route with a secret so strangers can't trigger it
  • Schedule a nightly call with pg_cron and pg_net, with the time written in UTC
  • Check that a job ran, and fix one that didn't

The everyday picture

Think of a shop owner who asks the night guard to phone at 11 pm every night and read out the till total. The guard has an alarm clock, a phone number, and a code word, so nobody else can call pretending to be him and get the shop to do something. If the call doesn't come, the owner knows something is wrong.

The alarm clock is the schedule, the phone call is a web request, and the code word is your secret.

Two ways to run something on a schedule

A is written as a . Both options below call a route on your site; the route does the work.

  1. Vercel Cron. Your agent adds a schedule to vercel.json. Easy, but on the Hobby plan a job can run at most once a day and the exact minute isn't promised. If you set a CRON_SECRET variable, Vercel sends it in the request's Authorization header for you.
  2. Supabase pg_cron plus pg_net. runs on a schedule inside the database, and lets that SQL call your site. Any schedule works, every 10 minutes included. This is what Kolom uses for its own nightly owner report.

One trap catches everyone: pg_cron schedules are in UTC. 23:00 in Dhaka (UTC+6) is 17:00 UTC, so you write 0 17 * * *. Work out your own offset once and write it in a comment.

Quick check

You want the report at 22:00 in Lagos (UTC+1), using pg_cron. Which schedule is right?

Loading the rest of the lesson…