# Scheduled jobs

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

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://run.docs.sypnia.com/jobs/cron/

For agents: Run scheduled jobs: [run.apps.<name>.jobs.<job>] tables in sypnia.toml with schedule (cron or rate()), timezone (IANA, DST handled), run file (@sypnia/run/job), timeout (default 300 s, ≤900 on Lambda, unlimited fargate), retries (attempts in all, default 5, 1–20, growing waits), overlap skip|allow, environments (production only by default); EventBridge Scheduler; at-least-once (make idempotent); runs recorded (run jobs runs), manual trigger (run jobs trigger).

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](https://run.docs.sypnia.com/cases/starts#scheduled-the-clock)).

`sypnia.toml`

```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"
```

```ts
// 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.
