Back to guides

Guides · April 9, 2026

Supabase cron jobs: Supabase Cron, pg_cron, and Edge Functions

Supabase Cron is pg_cron with a Dashboard on top: off by default, UTC only, and silent when an Edge Function call fails. Here is the setup end to end, a builder for the SQL, and where an external clock fits better.
crontap.com / guides
Database clock connected by an arrow to an Edge Function lightning-bolt icon.

Something in your Supabase project has to happen on a clock: expire old sessions every night, refresh a leaderboard every five minutes, or call the Edge Function that sends the morning digest. Supabase has a scheduler for exactly this, but it is switched off until you turn it on, and the first week with it tends to bring the same three surprises. Every schedule runs in UTC, a run marked succeeded can belong to an Edge Function that returned a 500, and nothing retries.

This guide covers the in-project path end to end (checked against Supabase's docs in November 2026), gives you a builder that writes the cron.schedule(...) SQL for you, and shows where an external HTTP clock fits better. If you only care about Edge Functions, the shorter cron jobs for Supabase Edge Functions page covers that setup.

Supabase Cron is pg_cron with a Dashboard on top

pg_cron is the Postgres extension that actually schedules and runs jobs. Supabase Cron is the Dashboard module built on it: the same jobs in the same cron.job table, with a form, a job list and a History view instead of hand-written SQL. Anything you create in one shows up in the other.

It is not enabled by default. Open Integrations > Cron in the Dashboard and enable the pg_cron extension (or run create extension pg_cron with schema pg_catalog;). Disabling it later deletes every job, so treat that switch with care.

Supabase sets two soft limits worth knowing before you add a tenth job:

8

Concurrent jobs

Supabase's recommended ceiling, as of Nov 2026

10 min

Per run

Recommended maximum runtime

1-59 s

Shortest interval

Postgres 15.1.1.61 or later

Supabase recommends no more than eight jobs running concurrently and a maximum runtime of ten minutes per job. Under the hood pg_cron allows up to 32 concurrent jobs, each holding a database connection, which is why the recommendation is much lower than the hard limit: every running job competes with your app for connections.

Path 1: schedule SQL with cron.schedule

The SQL route is three arguments: a job name, a schedule and the command. This one deletes expired sessions every night:

select cron.schedule(
  'nightly-cleanup',
  '0 2 * * *',
  $$delete from public.app_sessions where expires_at < now()$$
);

That runs at 02:00 UTC. Supabase's own examples label their schedules GMT, which is the same offset, and pg_cron's cron.timezone setting (default GMT) is not one of the Postgres settings Supabase lets you change. If your team thinks in New York time, a job meant for 02:00 local has to be written as 0 7 * * * in winter and 0 6 * * * in summer, and someone has to remember to change it twice a year.

A few behaviours that are easy to trip over:

  • Names are case sensitive and permanent. Calling cron.schedule again with the same name replaces the job, which is handy for edits and dangerous for typos.
  • Edit with cron.alter_job (schedule, command or active), and remove a job with select cron.unschedule('nightly-cleanup');. List everything with select * from cron.job;.
  • $ means the last day of the month in the day field, so 0 12 $ * * runs at noon UTC on the 28th, 30th or 31st as appropriate.
  • Overlaps queue instead of stacking. pg_cron runs different jobs in parallel but only one instance of a specific job at a time. If the same job becomes due while its previous run is still working, the new run queues and starts after the current one finishes.

For sub-minute work, swap the cron expression for an interval like '30 seconds'. The Supabase Cron quickstart accepts 1 to 59 seconds on Postgres 15.1.1.61 or later. Seconds can't be mixed with other fields, and an interval job has no wall-clock time: it fires every N seconds from when the scheduler picks it up.

Generate the cron.schedule SQL

Pick what the job runs, type a schedule (or tap a preset), and copy the files. The next runs show in UTC next to your own timezone, which is usually the moment the UTC rule sinks in.

cron.schedule builder

Supabase docs as of Nov 2026

What should the job run?

At 02:00 UTC, every day.

About 1 run a day, 30 in a 30-day month.

Next runs

pg_cron (UTC)Local
  
  
  
-- Run once. Keeps the URL and the key out of cron.job.
select vault.create_secret('https://<project-ref>.supabase.co', 'project_url');
select vault.create_secret('<sb_secret_ key>', 'secret_key');

Use a secret key, never the publishable key: anyone holding a publishable key could call the function.

pg_cron reads 0 2 * * * in UTC. Crontap reads the same expression in your timezone, retries failed calls and alerts you when the attempts run out.

Schedule your first job

SQL updates as you type. Placeholders sit in angle brackets.

Everything is generated in your browser. The Edge Function path follows Supabase's Scheduling Edge Functions guide as of November 2026; replace the values in angle brackets before running it.

The builder always adds cleanup.sql, and it is not decoration. Rows in cron.job_run_details are never removed automatically, not even when you unschedule a job. A job that runs every 30 seconds writes almost 90,000 rows a month, so give the history its own nightly cleanup job early.

Path 2: call an Edge Function from pg_cron with pg_net

When the work lives in an Edge Function, the scheduled command makes an HTTP request with pg_net. In the Dashboard, choose Supabase Edge Function as the job type and Supabase writes this for you. In SQL it takes three steps.

  1. 1

    Store the URL and a secret key in Vault

    Supabase's current guide uses a secret key (the sb_secret_... kind), never the publishable key, which is public and would let anyone call the function. Vault keeps both values out of the job text that anyone reading cron.job can see.

    select vault.create_secret('https://<project-ref>.supabase.co', 'project_url');
    select vault.create_secret('<sb_secret_ key>', 'secret_key');
  2. 2

    Schedule net.http_post with the key on the apikey header

    select cron.schedule(
      'nightly-digest',
      '0 7 * * *',
      $$
      select net.http_post(
        url := (select decrypted_secret from vault.decrypted_secrets where name = 'project_url')
          || '/functions/v1/nightly-digest',
        headers := jsonb_build_object(
          'Content-Type', 'application/json',
          'apikey', (select decrypted_secret from vault.decrypted_secrets where name = 'secret_key')
        ),
        body := jsonb_build_object('scheduled_at', now()),
        timeout_milliseconds := 5000
      ) as request_id;
      $$
    );
  3. 3

    Accept the key in the function

    The key arrives on apikey, not as a user JWT, so turn the platform JWT check off for this function and let the handler check the key with withSupabase({ auth: "secret" }) from @supabase/server, as described in Securing Edge Functions. Older tutorials send the legacy service_role JWT as a bearer token instead; the secret key on apikey is the current recommendation.

Here is the part that confuses most people the first time a scheduled function fails. net.http_post(...) is asynchronous: it returns a request ID, and the HTTP request starts after the transaction commits. cron.job_run_details records the scheduler run that submitted it. The eventual HTTP status or error is separate in net._http_response, where responses are retained for six hours by default. This supported path does not add bounded retries or final-failure handling on its own.

pg_cron with pg_net, inside the project

  1. pg_cron

    Fires at 02:00 UTC

    UTC only
  2. cron.job_run_details

    return_message: SELECT 1

    succeeded
  3. pg_net queue

    Sends after commit

    2 s default timeout
  4. Edge Function

    Throws on bad data

    500
  5. net._http_response

    Kept for 6 hours

    status_code 500

Two tables, two answers. The scheduler row says succeeded because the SELECT that queued the request ran.

An external HTTP clock, outside the project

  1. Crontap

    Fires at 02:00 Europe/Berlin

    IANA timezone
  2. Edge Function

    Same function, same URL

    500
  3. Retries

    Exponential backoff

    5xx, timeouts
  4. Attempt history

    Status code, duration, error

    each attempt
  5. Notification

    Email, Slack, Discord, Telegram

    after the last attempt

One history row per attempt, retries for the failure classes you chose, and a notification after the last one.

The same failing 02:00 run, seen from inside the project and from an external clock.

When a job goes quiet: reading the history

Start with the scheduler's own table. In the Dashboard that is the job's History view; in SQL it is cron.job_run_details, filtered to anything that did not succeed:

select jobid, status, return_message, start_time
from cron.job_run_details
where status not in ('succeeded', 'running')
  and start_time > now() - interval '5 days'
order by start_time desc
limit 20;

For SQL jobs, return_message usually tells you everything (a constraint error, a statement timeout, job canceled). For Edge Function jobs a clean scheduler row proves only that the request was queued, so check net._http_response for status_code, timed_out and error_msg, and do it within six hours or the row is gone. The request ID is not stored in the run history, so match the two tables by time.

If nothing shows up at all, the scheduler itself may be down. Supabase's pg_cron debugging guide shows how to check for the pg_cron scheduler process in pg_stat_activity, and recommends a fast reboot to revive it and a Postgres upgrade to v15.6.1.122 or later for pg_cron 1.6.4's fixes. Two other causes worth ruling out early:

  • The project is paused. Supabase pauses Free projects after a week of low activity, and their jobs cannot run while paused. Paid projects are not paused for inactivity.
  • Supabase itself is having a bad day. Check is Supabase down? before you rewrite anything.

Path 3: keep the function, move the clock outside

pg_cron is a good clock for work that already lives in Postgres. Once the job is an HTTP endpoint, you want something you can test, a timezone that matches the team, and a failure that shows up in Slack instead of a log you only open after a customer asks.

That is the external HTTP cron pattern. The Edge Function stays exactly where it is; a scheduler outside the project calls its URL. Give the caller a dedicated secret that can trigger this one function and nothing else, rather than a project key with admin rights. For a custom bearer secret, disable the platform JWT check for this function. The handler still rejects requests that do not carry your secret:

# supabase/config.toml
[functions.nightly-digest]
verify_jwt = false
// supabase/functions/nightly-digest/index.ts
Deno.serve(async (req) => {
  const cronSecret = Deno.env.get("CRON_SECRET");
  const auth = req.headers.get("authorization");
  if (!cronSecret || auth !== `Bearer ${cronSecret}`) {
    return new Response("Unauthorized", { status: 401 });
  }
  // build and send the digest
  return new Response(null, { status: 204 });
});

Set the secret with supabase secrets set CRON_SECRET=.... In Crontap, add POST https://<project-ref>.supabase.co/functions/v1/nightly-digest, the header Authorization: Bearer <CRON_SECRET>, the expression 0 7 * * * and a timezone such as America/New_York. Press Perform test before you save to see the real status code come back.

New schedules retry 5xx responses, timeouts, and network failures by default. Every plan can turn retries on or off. Pro, Ultra, and legacy Pro can tune one to five retries, the starting delay, and whether to retry 429 or other 4xx responses.

History records each attempt with its status, status code, duration, size, and error summary. After the configured attempts are exhausted, a failed final attempt enters the schedule's configured notification handling. Email is available on every plan, while Slack, Discord, and Telegram notifications are available on paid plans. Configured notification thresholds and routing determine whether and where a notification is sent. Machine webhook Integrations are configured separately from those human-facing Notifications.

Be honest about what this does not fix. An external clock keeps calling on schedule while Supabase is paused or unavailable, and its history makes those failures visible, but the Edge Function and the database still cannot do the work until Supabase recovers. Retries are in-process with backoff, not a durable queue, so the function should be safe to run twice.

pg_cron or an external clock: how to decide

Most projects end up with both: SQL housekeeping in pg_cron, and the HTTP jobs that people care about on an external clock.

You needpg_cron / Supabase CronExternal HTTP cron (Crontap)
SQL that runs next to the dataYes, no network hopOnly through an endpoint
Intervals under a minute1 to 59 secondsNo, one minute is the shortest
A schedule in your team's timezoneUTC onlyAny IANA timezone, per schedule
One place to see whether the call workedTwo tables, HTTP results kept 6 hOne history row per attempt
Retries on failureNoneConfigurable, exponential backoff
Someone told when it keeps failingNot built inEmail on every plan; Slack, Discord, Telegram on paid
Runs while a Free project is pausedNoCalls continue and fail visibly
CostIncluded in the projectFree for 2 schedules (hourly); Pro from $2.99/mo for every minute

The short version: if the job is SQL, or needs to run every few seconds, keep it in pg_cron and add a heartbeat if silence would hurt. If the job is an Edge Function that sends email, charges cards or syncs a partner API, the clock matters less than knowing it failed, and that is what an external scheduler is for.

Keep reading

FAQ

Supabase cron job questions

Is pg_cron enabled by default on Supabase?
No. Open Integrations > Cron in the Supabase Dashboard and enable it, or run create extension pg_cron with schema pg_catalog. Disabling the extension later deletes every job.
What is the difference between Supabase Cron and pg_cron?
pg_cron is the Postgres extension that schedules and executes jobs. Supabase Cron is the Dashboard module built on it, with a job form, a History view, and targets for SQL, database functions, HTTP requests, and Edge Functions. Jobs created either way live in the same cron.job table.
What timezone does Supabase Cron use?
UTC. Supabase's examples label schedules GMT, which is the same offset, and there is no per-job timezone. A job meant for 02:00 in New York has to be written in UTC and adjusted when daylight saving time changes. An external scheduler with a per-schedule IANA timezone avoids that.
Can Supabase Cron run every second?
Yes. On Postgres 15.1.1.61 or later, pg_cron accepts intervals from 1 to 59 seconds, written as '30 seconds'. Seconds cannot be combined with other cron fields, and a five-field cron expression still has one-minute precision.
What happens when the same pg_cron job overlaps?
pg_cron runs only one instance of a specific job at a time. If the next run is due before the current one finishes, the next instance queues and starts when the current one completes. Supabase recommends no more than eight jobs running concurrently and at most ten minutes per run.
How do I invoke a Supabase Edge Function on a schedule?
Choose Supabase Edge Function as the job type in Supabase Cron, or schedule a net.http_post call with pg_cron and pg_net. Supabase's current guide stores the project URL and a secret key in Vault, sends the key on the apikey header, and has the function accept it with verify_jwt = false and withSupabase({ auth: 'secret' }). Never use the publishable key for this.
How do I inspect Supabase Cron failures?
Open the job's History view or query cron.job_run_details for the pg_cron run status and return message. For an asynchronous pg_net request, inspect net._http_response for the eventual HTTP status or error; responses are retained for six hours by default.
Why does cron.job_run_details say succeeded when my Edge Function failed?
Because the scheduled command only queues the HTTP request. The run succeeds as soon as net.http_post returns a request ID; the Edge Function's status code, timeout flag or error lands later in net._http_response. Check that table within six hours, and raise timeout_milliseconds above the 2,000 ms default if the function is slow.
Does Supabase Cron retry failed jobs?
No. Neither pg_cron nor pg_net retries a failed run or request, and nothing notifies you on its own. You can add a heartbeat ping at the end of the job to hear about silence, or call the Edge Function from an external scheduler that retries configured failures and sends a notification when the attempts run out.
What happens to cron jobs when a Free project is paused?
The database scheduler and Edge Function workload are unavailable until the project resumes. Supabase pauses Free projects after a week of low activity; paid projects are not paused for inactivity. An external scheduler can keep attempting the URL and record failures, but it cannot make the paused Supabase workload succeed.

Same Edge Function, a clock you can see

Send the digest at 07:00 in New York, not 07:00 UTC.

Paste the function URL, add the Authorization header with your CRON_SECRET, and press Perform test to see the real status code before you save. Supabase keeps running the function; Crontap keeps the clock in your timezone, retries the failures and alerts you when the attempts run out.

Free for 2 schedules or monitors. No card.

POSThttps://your-project.supabase.co/functions/v1/nightly-digest
Active

0 7 * * *America/New_York

Next run in ...

Run history

From the blog

Read the blog

Guides, patterns and product updates.

Tutorials on scheduling API calls, webhooks and automations, plus deep dives into cron syntax, timezones and reliability.

Product

Introducing Crontap status pages

Publish uptime monitors and heartbeats on a public page at crontap.page, pick a template from Clean to a split-flap departures board, and add incidents, maintenance and a badge.

Product

Slack, Discord and Telegram alerts are here

Connect a chat channel once, then route schedule, uptime and heartbeat alerts with defaults, per-job overrides and test sends. See what each alert looks like in Slack, Discord, Telegram and email.

Product Updates

Introducing AI Integrations

Transform a schedule's HTTP response with a plain-English prompt, return text or JSON, and forward it to Slack, Make, n8n, or your own endpoint. Test on any tier; saving is a Pro feature.