Scheduled tasks
Work that runs on a timetable: nightly reports, reminders, clean-ups.
In stackly.json and the CLI it is scheduled-tasks. Its use, live or draft, is counted as background runs; see Live app prices.
scheduled-tasks · optional · needs backend · Durable Object alarms feeding the app's queue (cron, UTC)
Work that runs on a timetable: nightly reports, reminders, clean-ups.
Turn it on
"features": ["backend", "scheduled-tasks"],
"schedules": [{ "name": "nightly-report", "cron": "0 3 * * *" }]
Use it
Handle each schedule by name in src/server/tasks.ts:
schedules: {
"nightly-report": async (context) => {
await buildReport(new Date(context.createdAt));
},
},
- Five cron fields in UTC, or
@hourly,@daily,@weekly,@monthly. - A handler that throws is retried like a job. Make it safe to run twice. Hand big work to
queuesjobs.
Limits
At most 20 schedules. A handler gets 60 s.
Locally
Schedules run only on live; the draft never runs them. stackly dev runs them, so they can be tried.