基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mikailustuner/OmniRule --skill cron-jobs命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Bun runtime: HTTP server, file I/O, SQLite, test runner, package manager, bundler — all-in-one JS toolchain.
Clerk: Drop-in auth UI, Organizations, User management, JWT templates, webhooks, Next.js middleware integration.
Gelişmiş masaüstü, tarayıcı ve işletim sistemi kontrol yeteneği. Görsel (koordinat tabanlı) fare/klavye otomasyonu, DOM manipülasyonu, pencere yönetimi, gelişmiş dosya, ağ ve süreç yönetimini kapsar.
| name | cron-jobs |
| description | Cron jobs: Scheduling patterns, idempotency strategy, failure handling, monitoring. |
| triggers | {"keywords":["cron","schedule","recurring","job","BullMQ","queue","worker","background"]} |
| auto_load_when | Setting up scheduled or background jobs |
| agent | devops-engineer |
| tools | ["Read","Write","Bash"] |
Focus: Scheduling, reliability, failure handling
Cron makes sense when:
├── Scheduled tasks needed
│ └── Daily reports, cleanup jobs
│ └── Hourly sync, weekly summaries
│
├── Not real-time critical
│ └── Can tolerate few minutes delay
│ └── Batch processing
│
├── Predictable schedule
│ && Fixed times, known intervals
│ && Not based on events
│
└── Simple trigger mechanism
└── Time-based only
└── No complex dependencies
Don't use cron when:
├── Event-driven
└── Triggers on user actions
└── Use message queues instead
│
├── Real-time needed
└── Sub-second requirements
└── Use streaming
│
└── Complex dependencies
&& Job B depends on Job A result
&& Use workflow orchestrator
Why idempotency matters:
├── Cron can run multiple times
│ └── Previous run didn't complete
│ || System restarted mid-run
│
├── Network failures cause retries
└── Must handle duplicate execution
How to achieve:
├── Check before work
&& Query: "Is this already processed?"
&& Upsert instead of insert
│
├── Use unique constraints
&& Database prevents duplicates
└── Deduplicate at source
│
├── Track processed items
&& Record each processed ID
&& Skip if already in list
│
└── Timestamp-based
&& Process records created in time window
&& No reprocessing of old records
What to do on failure:
├── Retry strategy
&& Internal retry: 3 attempts with backoff
&& External: let cron retry next schedule
&& Exponential backoff
│
├── Dead letter
&& Move to failed queue
&& Manual investigation
&& Don't block next run
│
├── Alerts
&& Notify on failure
&& Include: job name, time, error
&& Don't alert on every retry
│
└── Partial progress
&& Save checkpoint
&& Resume from last point
&& Track what succeeded
What to monitor:
├── Execution status
&& Did it run at all?
&& Did it complete?
&& How long did it take?
│
├── Output/logs
&& Store where searchable
&& Include context (date, params)
│
└── Metrics
&& Records processed
&& Errors encountered
&& Time trend
Alerting thresholds:
├── Didn't run → Critical
&& Schedule missed
&& Cron broken
│
├── Failed → Warning
&& Business impact
&& Needs investigation
│
├── Slow → Warning
&& Resource issues
&& Data growth
│
└── Zero output → Warning
&& Business unusual?
|| Data pipeline broken
How to handle time zones:
├── UTC for infrastructure
&& Cron runs in UTC
&& Logs in UTC
&& Simple, consistent
│
├── Business timezone for business
&& "Daily report at 9am business time"
&& Calculate UTC at runtime
&& Document business hours
│
└── User timezone for UI
&& Show next run in user time
|| Store schedule in business time
❌ Multiple instances running the same cron simultaneously
✅ Distributed lock (Redis SET NX) before executing cron job
❌ Cron jobs with no logging or alerting
✅ Log start/end/duration; alert on failure or long runtime
❌ Cron times in local timezone
✅ Always use UTC in cron expressions
❌ Heavy work blocking the cron process
✅ Cron dispatches a job to a queue; worker handles the heavy lifting
❌ No graceful shutdown handling
✅ Handle SIGTERM; complete current job, reject new during shutdown
| Expression | Meaning | Example |
|---|---|---|
* * * * * | Every minute | Health check |
0 * * * * | Every hour | Hourly rollup |
0 0 * * * | Daily midnight UTC | Daily report |
0 0 * * 0 | Weekly Sunday | Weekly summary |
*/5 * * * * | Every 5 minutes | Polling job |
| Library | Runtime | Note |
|---|---|---|
| node-cron | Node.js | In-process |
| BullMQ repeat | Node.js | Queue-backed |
| Inngest | Serverless | Managed |
| GitHub Actions schedule | CI | Simple periodic |