Recurring: cron(...)
Declare a cron in your manifest. It fires a function every time the schedule matches (the scheduler checks once a minute).
app.ts
functions/ — a normal query / mutation / action:
functions/hourlyRollup.ts
Make cron functions
internal: true. A cron function is also a regular function, so without internal: true it’s reachable at /api/fn/<name>. Marking it internal means only the scheduler (and ctx.runMutation) can invoke it.ctx.db.* calls run server-side and aren’t subject to entity policies (those gate client sync, not trusted server code), so a maintenance cron reads and writes its entities directly.
Elevate only in two cases, and always with an audit reason:
reason is mandatory — every elevation is logged so an operator can audit who elevated and why. Pylon never grants admin to a cron implicitly.
Schedule format. Standard 5-field cron: minute hour day-of-month month day-of-week. A schedule that doesn’t parse, or a function name that isn’t registered, is logged loudly at boot and skipped — so a typo fails visibly in pylon dev instead of silently never running.
Durability. Cron jobs are backed by a persistent job store, so a fire that’s in flight survives a restart, and the schedule resumes after a redeploy.
One-shot: ctx.scheduler
To run something later (not on a repeating schedule), schedule it from inside a mutation or action:
args you pass are delivered verbatim. Like crons, these are durable across restarts.