diff --git a/CHANGELOG.md b/CHANGELOG.md index b679547..27d193b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Cloudflare Workers `scheduled` handler that POSTs to the Claude Code routine `/fire` endpoint. -- Default 20×daily cron at UTC+7 — 00:00 once, then hourly 05-09 / 10-14 / 15-19 / 20-23 with stepped minute offsets (:01-:04). Packed into 5 cron expressions to fit the CF free-tier limit. +- Default 20×daily cron at UTC+7 — fires at 00:00 and hourly from 05:00 through 23:00. Single cron expression (`0 0-17,22-23 * * *`). - Token-substitution template with `{ISO}`, `{LocalTime}`, `{Cron}` (default: `Scheduled trigger at {LocalTime}`). - IANA timezone support via `TZ` env var (default: `UTC`). - Structured JSON logs for fire success / non-2xx / network failure. diff --git a/README.md b/README.md index cff813a..11c582f 100644 --- a/README.md +++ b/README.md @@ -60,11 +60,7 @@ Edit `wrangler.toml` `[triggers].crons` — Cloudflare requires literal cron exp ```toml [triggers] crons = [ - "0 17 * * *", # 00:00 UTC+7 (17:00 UTC prev day) - "1 22,23,0,1,2 * * *", # 05:01-09:01 UTC+7 - "2 3-7 * * *", # 10:02-14:02 UTC+7 - "3 8-12 * * *", # 15:03-19:03 UTC+7 - "4 13-16 * * *", # 20:04-23:04 UTC+7 + "0 0-17,22-23 * * *", # UTC+7: 00:00 + 05:00..23:00 hourly ] ``` @@ -73,8 +69,8 @@ Then redeploy: `npx wrangler deploy`. Tips: - Cron runs in **UTC**. Convert your local time: `UTC = local − offset` (e.g. 09:00 UTC+7 → 02:00 UTC → `0 2 * * *`). - Validate expressions at . -- **Free tier limit:** 5 cron expressions per worker. Default config uses all 5. Use comma lists (`1 22,23,0,1,2 * * *`) and ranges (`2 3-7 * * *`) to fit more fires per row. -- Standard 5-field syntax — supports `*`, `,`, `-`, `/`. Use minute offsets (`:01`, `:02`, …) instead of `:00` to avoid top-of-hour contention on shared infra. +- **Free tier limit:** 5 cron expressions per worker. Default config uses 1. +- Standard 5-field syntax — supports `*`, `,`, `-`, `/`. Comma lists (`22,23,0,1,2`) and ranges (`3-7`) let you cram many fires into one expression. ## Templates diff --git a/wrangler.toml b/wrangler.toml index 2e7acc1..96325e5 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -11,22 +11,12 @@ TZ = "Asia/Ho_Chi_Minh" # Cron triggers fire from this list. CF Workers requires literal cron # expressions here — they cannot be loaded from env vars or secrets. -# Schedule (Asia/Ho_Chi_Minh, UTC+7) — 20 fires/day, packed into 5 expressions: -# 00:00 — once at local midnight -# 05:01-09:01 — every hour, minute 01 -# 10:02-14:02 — every hour, minute 02 -# 15:03-19:03 — every hour, minute 03 -# 20:04-23:04 — every hour, minute 04 -# Crons evaluate in UTC, so each row is offset by -7 hours; the 05-09 row -# wraps midnight UTC so it uses a comma list rather than a range. -# Free tier allows up to 5 cron expressions per worker — at limit. +# Schedule (Asia/Ho_Chi_Minh, UTC+7): hourly at :00 from 05:00 to 23:00, +# plus a single fire at 00:00 — 20 fires/day, every hour except 01-04. +# Crons evaluate in UTC; UTC+7 hours {00, 05..23} map to UTC {17, 22-23, 0-16}. [triggers] crons = [ - "0 17 * * *", # 00:00 UTC+7 (17:00 UTC prev day) - "1 22,23,0,1,2 * * *", # 05:01-09:01 UTC+7 - "2 3-7 * * *", # 10:02-14:02 UTC+7 - "3 8-12 * * *", # 15:03-19:03 UTC+7 - "4 13-16 * * *", # 20:04-23:04 UTC+7 + "0 0-17,22-23 * * *", # UTC+7: 00:00 + 05:00..23:00 hourly ] # Built-in observability (free tier supports basic logs).