render-cron-jobs
在 Render 上用 cron job 服务配置并排查定时任务。当用户需要按计划运行任务、编写 cron 表达式、设置周期性任务、从 Heroku Scheduler 迁移、在 cron job 与后台 worker 之间做选择,或修复未触发的 cron 时使用。触发词:cron job、scheduled task、periodic job、cron expression、schedule、run every、timer、Heroku Scheduler migration。
- License 许可
- MIT
- 最近更新
- 2026-11-08
- Stars
- ★ 37
- Forks
- 1
01 前言 Front Matter
- name
- render-cron-jobs
- license
- MIT
- metadata
- { "author": "Render", "version": "1.0.0", "category": "compute" }
- description
- 在 Render 上用 cron job 服务配置并排查定时任务。当用户需要按计划运行任务、编写 cron 表达式、设置周期性任务、从 Heroku Scheduler 迁移、在 cron job 与后台 worker 之间做选择,或修复未触发的 cron 时使用。触发词:cron job、scheduled task、periodic job、cron expression、schedule、run every、timer、Heroku Scheduler migration。
- compatibility
- Render cron job services
02 资源文件 3
- 参考文档agents/openai.yaml214 B
- 参考文档references/cron-patterns.md2.7 KB
- 参考文档references/migration-from-scheduler.md2.8 KB
03 SKILL.md 正文
Render Cron Jobs
This skill covers Cron Job services on Render: how schedules run, what the platform guarantees, and how they differ from workers and workflows. Pair it with Blueprint and deploy skills when authoring render.yaml or Dashboard settings.
When to Use
- Scheduled work that starts on a cron, runs a command, and exits when finished
- Choosing between cron, background worker, or workflow for periodic or long-running jobs
- Blueprint fields for
type: cron,schedule, and commands - Constraints: no disk, single concurrent run, 12-hour max duration, private-network outbound only
- UTC scheduling pitfalls (expressions are not local time)
Expression cheat sheets, framework startCommand examples, and Heroku Scheduler migration mapping live under references/.
Configuration
- Schedule: a cron expression evaluated in UTC, not the team’s local timezone. All times in the Dashboard and Blueprints are UTC.
- Command: any valid Linux shell command or bash script path. The process must exit when work is done—billing is based on run duration (prorated by the second).
- Source:
- Git repository — Render builds on push (same deploy model as other repo-backed services); the built artifact runs on each scheduled invocation.
- Prebuilt Docker image — the image is pulled before each run and is not retained between runs (no warm cache of the image layer set across invocations in the same way as a long-lived service).
Constraints
- No persistent disk — cron job services cannot provision or attach Render persistent disks; plan for object storage or databases instead.
- Single-run guarantee — at most one active run per cron service at a time. A new scheduled tick does not start a second overlapping instance.
- Maximum run length: 12 hours per invocation.
- Pricing: $1/month minimum per cron job service; usage is prorated by the second beyond plan/minimum rules that apply to your account.
- Private network: cron jobs can send traffic to other services on the private network; they cannot receive inbound private-network connections (no internal hostname for accepting traffic from other services).
Execution Behavior
- Manual “Trigger Run” while a run is active: Render cancels the active run, then starts a new one.
- New Git build / deploy does not affect a run already in progress—the in-flight process keeps using the revision it started with until it exits.
- Docker-based crons: the image is pulled fresh for each run; do not assume layer or image reuse across invocations like a continuously running container.
- UTC everywhere: cron expressions and “midnight” in docs mean UTC. A common mistake is copying a local-time schedule into the expression without converting to UTC.
Cron vs Worker vs Workflow
| Need | Use | Why |
|---|---|---|
| Periodic task under 12h | Cron Job | Scheduled, simple, exits when done |
| Continuous job processing | Background Worker | Always running, polls a queue |
| Periodic but over 12h | Background Worker | No 12h cron run ceiling |
| Scheduled parallel compute | Cron Job + Workflow | Cron triggers workflow runs on a schedule; workflows fan out or orchestrate parallel steps |
Blueprint Configuration
Cron services use type: cron with a schedule and the usual build/start and env wiring:
services:
- type: cron
name: nightly-cleanup
schedule: "0 * * * *" # hourly at minute 0 — must be quoted in YAML
buildCommand: pip install -r requirements.txt
startCommand: python cleanup.py
envVars:
- key: DATABASE_URL
fromDatabase:
name: my-db
property: connectionString
schedule: standard five-field cron (minute hour day-of-month month day-of-week), UTC.buildCommand/startCommand: same roles as other non-Docker services; Docker images use image + start command as configured for image-backed crons.envVars: same patterns as web services and workers (secrets, linked databases, etc.).
YAML note: the schedule value must be quoted so characters like * are not parsed as YAML aliases or flow syntax.
Common Patterns
- Database cleanup — archive or delete stale rows on a schedule
- Report generation — build CSV/PDF and upload to object storage or email
- External API sync — pull or push batches on an interval
- Cache warming — hit endpoints or rebuild caches before peak traffic
- Scheduled emails — digest or reminder sends driven by cron + mail/API
References
| Topic | File |
|---|---|
| Expression examples, framework commands, errors, env vars | references/cron-patterns.md |
| Heroku Scheduler → Render mapping, blueprint example | references/migration-from-scheduler.md |
Related Skills
- render-deploy — First-time deploy, service creation, Dashboard flow
- render-blueprints — Full
render.yamlschema, previews, common mistakes - render-background-workers — Long-lived processes, queues, no 12h cap
- render-workflows — Orchestrated and parallel jobs, often triggered on a schedule from cron
04 同仓库更多 Skills
android-emulator-qa
Use when validating Android feature flows in an emulator with adb-driven launch, input, UI-tree inspection, screenshots, and logcat capture.
supabase-postgres-best-practices
Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
sentry
Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.
render-workflows
搭建、开发、测试和部署 Render Workflows。涵盖首次脚手架搭建(通过 CLI 或手动方式)、SDK 安装(Python 或 TypeScript)、任务模式(重试、子任务、扇出)、本地开发、控制台部署和故障排查。适用于用户首次搭建 Render Workflows、构建工作流服务、添加或修改工作流任务、本地测试工作流或部署到 Render 的场景。
render-web-services
配置 Render web service——端口绑定、TLS、健康检查、自定义域名、自动部署、PR 预览、持久化磁盘及部署生命周期。当用户需要搭建 web service、修复健康检查失败、添加自定义域名、配置零停机部署,或排查端口绑定问题时使用。
render-static-sites
在 Render 全球 CDN 上部署并配置静态站点——构建命令、发布路径、SPA 路由、重定向、自定义 header 及 PR 预览。当用户需要部署静态站点、搭建 React/Vue/Hugo/Gatsby 前端、配置 SPA 回退路由、添加重定向规则、自定义响应 header,或在静态站点与 web service 之间为前端做选择时使用。触发词:static site、CDN、SPA、single-page app、React deploy、Vue deploy、Hugo、Gatsby、Docusaurus、Jekyll、staticPublishPath。