Scheduled jobs
Run code on a schedule, in your time zone, with retries and a record of every run.
On this page
A job is code that runs on a schedule. It belongs to an app and is deployed with it, so a job always runs the code of the deploy production points to.
A use case on your map that starts scheduled becomes a job like these, declared on the map instead of here (How each case starts).
[run.apps.laespiga.jobs.close-day]
schedule = "0 21 * * *"
timezone = "America/Bogota"
run = "jobs/close-day.ts"
timeout = 300
[run.apps.laespiga.jobs.reminders]
schedule = "rate(15 minutes)"
run = "jobs/reminders.ts"
overlap = "skip"// jobs/close-day.ts
import { job } from '@sypnia/run/job';
export default job(async (ctx) => {
ctx.log('closing the day', { at: ctx.scheduledAt });
// …
});Fields
| Field | Default | What it does |
|---|---|---|
schedule | — | A cron expression (min hour day month weekday) or rate(N minutes|hours|days) |
timezone | UTC | IANA name; daylight saving is handled |
run | — | The file whose default export is the job |
timeout | 300 s | Up to 900 s on Lambda; a container job (runtime = "fargate") has no limit |
retries | 5 | Attempts in all, 1 to 20, with growing waits; after the last one the run is recorded as failed |
overlap | skip | skip a run while the previous one is still running, or allow |
environments | ["production"] | Where the job runs; previews never run jobs unless listed |
Guarantees
A run starts at least once per scheduled time: after a platform failure a run can start twice, so make jobs safe to repeat (check what is already done). Each run is recorded with its start, end, status and logs: run jobs runs close-day. run jobs trigger close-day starts one now.