Guide
Scheduling AI agent routines: cron patterns that stay cheap
A routine is what turns an agent from “something you remember to ask” into a job that runs itself. The hard part isn’t the cron line — it’s picking when to wake, and what to do when there’s nothing worth doing.
1. Pick the trigger before the schedule
Ask first: does something happen that should wake the agent (a PR opened, a message posted, a form submitted)? If yes, use an event trigger or webhook. GitHub’s own docs put it plainly: webhooks deliver data as it happens and take less effort and fewer resources than polling an API. Save cron for work that is genuinely time-based — digests, weekly reviews, “check the queue each morning.”
- Event trigger — PR opened, CI finished, Slack message, incoming webhook. Runs only when there’s input.
- Schedule — daily brief, weekday publishing slot, end-of-week summary.
- Both — many tools let one routine have several triggers; it runs when any of them fires.
2. Cron patterns worth copying
Standard five-field cron (minute hour day-of-month month day-of-week):
7 8 * * 1-5— 08:07 on weekdays. The classic “morning brief” slot.37 17 * * 5— 17:37 Friday. Weekly wrap-up or review.17 9-17/2 * * 1-5— every two hours during a weekday working window.23 7 1 * *— first of the month, for monthly reports or cleanups.
Check the timezone: Cloudflare Cron Triggers run on UTC, and GitHub Actions schedules
default to UTC unless you set one. Cloudflare also numbers weekdays 1 = Sunday, unlike
most cron systems — use MON–FRI names to avoid surprises.
3. Avoid the top of the hour
Everyone schedules at :00. GitHub notes that scheduled workflows can be
delayed during high load, which includes the start of every hour, and recommends a
different minute. Cursor’s scheduled triggers may also start late (never early). Pick an
odd minute like :07 or :43, and don’t write routines that break
if they run a few minutes late.
4. Be quiet when nothing changed
The most useful rule for a scheduled agent: if there’s nothing new, do nothing and say nothing. A daily “no updates today” message trains people to ignore the bot.
- Check cheaply first — look at a timestamp, count, or hash before invoking a model at all.
- Write a quality bar into the prompt — spell out when to comment, open a PR, publish, or do nothing.
- Keep a small memory — store what was already handled so the next run skips it.
- Exit silently — no summary, no ping, no deploy when the answer is “nothing.”
5. Keep token and usage cost down
- Run less often — hourly is 24× as many wakes as daily. Most digests don’t need to be fresher than once a morning.
- Narrow the input — pass only what changed since the last run, not the whole inbox or repo.
- Keep the prompt prefix stable — providers such as xAI cache repeated leading messages automatically and bill cached tokens at a reduced rate, so put fixed instructions first and variable data last.
- Start simple — a single well-scoped call on a schedule often beats a multi-step agent loop. Add agentic steps only when the task needs them.
- One job per routine — a narrow job has smaller context and is easier to tell whether it did anything.
6. A quick checklist
- Is there an event I could trigger on instead of polling?
- Is the schedule in the timezone I think it is?
- Is it off the top of the hour?
- Does it exit silently when there’s nothing to do?
- Does it remember what it already handled?
- Could it run half as often without anyone noticing?
Useful public resources
Type a cron expression and see it in plain English. The fastest way to sanity-check a schedule.
Scheduled (cron) and event triggers for cloud agents: GitHub, Slack, webhooks, Linear, and more, plus memories and prompt tips.
Run a Worker on a schedule; supported cron syntax, UTC timing, and local testing.
The schedule event, timezone option, load delays at the top of the hour, and every event trigger.
A clear explanation of webhooks vs polling, and when to choose each.
How repeated prompt prefixes are cached automatically, and what breaks the cache.
Why simple, composable workflows usually beat complex agent frameworks.
New to narrow bots? Start with What is a one-job Grok Bot?