Skip to content
Cron

定时任务

Schedule Recurring Jobs with Cron Syntax in Postgres

Supabase Cron 是一个 Postgres 模块,它可以用 cron 语法简化定时重复任务的调度,并在 Postgres 内监控任务执行情况。

🌐 Supabase Cron is a Postgres Module that simplifies scheduling recurring Jobs with cron syntax and monitoring Job runs inside Postgres.

可以通过 SQL 或仪表板中的 集成 -> 定时任务 界面创建 Cron 任务,根据你的使用需求,它们可以每秒运行一次,也可以一年运行一次。

🌐 Cron Jobs can be created via SQL or the Integrations -> Cron interface inside the Dashboard, and can run anywhere from every second to once a year depending on your use case.

Manage cron jobs via the Dashboard

每个作业都可以轻松运行 SQL 片段或数据库函数,几乎没有网络延迟,或者发起 HTTP 请求,比如调用 Supabase Edge Function。

🌐 Every Job can run SQL snippets or database functions with zero network latency or make an HTTP request, such as invoking a Supabase Edge Function, with ease.

Cron 是怎么工作的? #

🌐 How does Cron work?

在底层,Supabase Cron 使用 pg_cron Postgres 数据库扩展,它是你任务的调度和执行引擎。

🌐 Under the hood, Supabase Cron uses the pg_cron Postgres database extension which is the scheduling and execution engine for your Jobs.

该扩展在你的数据库中创建了一个 cron 架构,所有的作业都存储在 cron.job 表中。每个作业的运行情况及其状态都会记录在 cron.job_run_details 表上。

🌐 The extension creates a cron schema in your database and all Jobs are stored on the cron.job table. Every Job's run and its status is recorded on the cron.job_run_details table.

Supabase 仪表板提供了一个界面,让你可以安排任务并监控任务运行。你也可以用 SQL 做同样的事情。

🌐 The Supabase Dashboard provides an interface for you to schedule Jobs and monitor Job runs. You can also do the same with SQL.

资源 #

🌐 Resources