convex-crons

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- GENERATED from convex-agents content/capabilities/crons.json — do not edit by hand. -->
<!-- 由 convex-agents content/capabilities/crons.json 生成——请勿手动编辑。 -->

Add scheduled jobs (crons)

添加定时任务(crons)

Define recurring jobs in convex/crons.ts targeting internal functions, with sane intervals and idempotent handlers.
在 convex/crons.ts 中定义定时任务,目标是内部函数,并设置合理的执行间隔和幂等处理程序。

Workflow

工作流程

  1. Create convex/crons.ts with cronJobs().
  2. Schedule internal functions (never public api.*) at the right interval.
  3. Make handlers idempotent (safe to re-run); keep each run small.
  4. Verify the job appears in the dashboard schedule.
  1. 使用 cronJobs() 创建 convex/crons.ts。
  2. 按合适的间隔调度内部函数(绝不能使用公共 api.* 函数)。
  3. 确保处理程序具备幂等性(可安全重复运行);每次运行应保持轻量。
  4. 验证任务是否出现在 dashboard 的 schedule 中。

Rules

规则

  • Schedule internal.* functions, never api.*.
  • Keep cron handlers small + idempotent.
  • Don't poll tight intervals for things a subscription can push.
  • 调度 internal.* 函数,绝不能调度 api.* 函数。
  • 保持 cron 处理程序轻量且具备幂等性。
  • 对于可以通过 subscription 推送的内容,不要使用高频轮询。