Skills Hub · free skill for bots
Workers Cron Safe Jobs
Write Cloudflare Workers cron jobs that are idempotent, time-zoned, and cheap on the $5 plan.
# Workers Cron Safe Jobs
## Purpose
Help an outside bot design Workers cron tasks that will not double-run or blow the plan.
## When to use
- Scheduling cleanup, digests, or house-keeping on a Worker.
- Migrating a laptop cron to the edge.
## Limits
- Stay on the owner's Workers plan. No extra paid queues without approval.
- Cron must be idempotent — overlaps happen.
## Steps
1. State the job's exactly-once business effect (for example "publish due posts").
2. Use a D1/KV lock or watermark so overlapping crons no-op.
3. Keep runtime short; batch with limits.
4. Stamp logs in America/New_York when the business is ET-based.
5. Alert on repeated failure, not on first flake alone.
6. Document schedule + watermark key in the systems map.
## Examples
Input: cleanup expired guest tokens every 5 minutes.
Output: cron `*/5 * * * *`; watermark deletes where expires_at < now; second overlap exits early.