Cron Jobs Agent Skill
Scheduled tasks with Vercel Cron, Inngest, node-cron, crontab syntax, and error handling.
The Skill
Full content, every format. Copy it, download it, or install with one command.
---
description: Scheduled tasks with Vercel Cron, Inngest, node-cron, crontab syntax, and error handling.
homepage: https://yepapi.com/skills/cron-jobs
metadata:
tags: [cron, scheduling, jobs, automation]
---
# Cron Jobs
## Rules
- Vercel Cron: define in `vercel.json` with `{ "crons": [{ "path": "/api/cron/task", "schedule": "0 * * * *" }] }`
- Secure cron endpoints: verify `Authorization: Bearer ${CRON_SECRET}` header — prevent unauthorized invocations
- Idempotent handlers — cron jobs can fire twice; always check if work was already done
- Timeout awareness: Vercel functions timeout at 10s (hobby) / 60s (pro) — offload long tasks to queues
- Inngest for complex scheduling: `inngest.createFunction({ id: "...", cron: "0 9 * * *" }, handler)`
- node-cron for self-hosted: `cron.schedule("*/5 * * * *", task)` — only for persistent servers
- Crontab syntax: `minute hour day month weekday` — use https://crontab.guru to verify
- Log every run with start time, end time, success/failure, items processed
- Error handling: wrap in try/catch, report failures to logging/alerting, don't let one failure stop the next run
## Patterns
```json
// vercel.json
{
"crons": [
{ "path": "/api/cron/daily-report", "schedule": "0 9 * * *" },
{ "path": "/api/cron/cleanup", "schedule": "0 0 * * 0" }
]
}
```
```ts
// Cron route handler
export async function GET(req: Request) {
const authHeader = req.headers.get("authorization");
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
return new Response("Unauthorized", { status: 401 });
}
try {
const result = await runScheduledTask();
return Response.json({ success: true, processed: result.count });
} catch (error) {
console.error("Cron job failed:", error);
return Response.json({ success: false, error: String(error) }, { status: 500 });
}
}
```
## Common Schedules
| Schedule | Cron | Description |
|----------|------|-------------|
| Every hour | `0 * * * *` | Top of each hour |
| Daily 9am UTC | `0 9 * * *` | Morning reports |
| Weekly Sunday | `0 0 * * 0` | Cleanup tasks |
| Every 5 min | `*/5 * * * *` | Polling/sync |
## Avoid
- Exposing cron endpoints without auth — anyone could trigger them
- Long-running work inside the handler — offload to a queue for tasks > 10s
- Assuming exact timing — cron jobs can be delayed; design for idempotency
- Forgetting error handling — one uncaught error should not break the scheduleInstall
Why Use the Cron Jobs Skill?
Without this skill, your AI guesses at cron jobs patterns. It might hallucinate deprecated APIs, use outdated conventions, or miss best practices entirely. With it, your AI follows a proven ruleset — every suggestion aligns with current standards.
Drop this skill into your project and your AI instantly knows the rules. Better code suggestions, fewer errors, faster shipping.
Try These Prompts
These prompts work better with the Cron Jobs skill installed. Your AI knows the context and writes code that fits.
"Set up Vercel Cron jobs for daily report generation and weekly email digests"
"Create a scheduled task system with retry logic, logging, and failure notifications"
"Build a cron job dashboard that shows run history, success rates, and next scheduled runs"
Works Great With
Cron Jobs skill — FAQ
It provides patterns for Vercel Cron, Inngest, and node-cron with crontab syntax and error handling. Your AI sets up reliable scheduled tasks with proper logging and failure recovery.
Run `npx skills add YepAPI/skills --skill cron-jobs` in your project root. This copies the skill file into your repo where your AI coding tool can read it automatically.
The skill includes retry logic with exponential backoff, error logging, and failure notifications. It covers both Vercel Cron (serverless) and node-cron (self-hosted) with proper timeout handling.