Skip to content

Scheduled jobs

Run code on a schedule, in your time zone, with retries and a record of every run.

Applies to EngineCloud
View as Markdown
On this page
  1. Fields
  2. Guarantees

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).

sypnia.toml
[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"
TypeScript
// jobs/close-day.ts
import { job } from '@sypnia/run/job';

export default job(async (ctx) => {
  ctx.log('closing the day', { at: ctx.scheduledAt });
  // …
});

Fields

FieldDefaultWhat it does
schedule—A cron expression (min hour day month weekday) or rate(N minutes|hours|days)
timezoneUTCIANA name; daylight saving is handled
run—The file whose default export is the job
timeout300 sUp to 900 s on Lambda; a container job (runtime = "fargate") has no limit
retries5Attempts in all, 1 to 20, with growing waits; after the last one the run is recorded as failed
overlapskipskip 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.

  1. Fields
  2. Guarantees

    Search pages, sections and terms