diff --git a/CHANGELOG.md b/CHANGELOG.md index f801ad5..b679547 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 5×daily cron at UTC+7 (00:07 / 05:13 / 10:19 / 15:23 / 20:37) — scattered minutes for shared-infra hygiene. +- 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. - 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 9f90dab..cff813a 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,11 @@ Edit `wrangler.toml` `[triggers].crons` — Cloudflare requires literal cron exp ```toml [triggers] crons = [ - "7 17 * * *", # 00:07 UTC+7 - "13 22 * * *", # 05:13 UTC+7 - # add / remove / edit these lines as needed + "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 ] ``` @@ -71,8 +73,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. To run more schedules, deploy another worker. -- Scattering minutes (e.g. `7`, `13`, `19`, `23`, `37`) is good hygiene on shared infrastructure even though CF cron is more reliable than GitHub. +- **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. ## Templates diff --git a/wrangler.toml b/wrangler.toml index cbecb1c..2e7acc1 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -11,17 +11,22 @@ 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. -# Default schedule mirrors the sibling repos: 5x daily at UTC+7 -# 00:07 / 05:13 / 10:19 / 15:23 / 20:37 — minutes scattered to avoid -# top-of-hour contention (good hygiene; CF cron is more reliable than GH). +# 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. [triggers] crons = [ - "7 17 * * *", - "13 22 * * *", - "19 3 * * *", - "23 8 * * *", - "37 13 * * *", + "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 ] # Built-in observability (free tier supports basic logs).