---
question: How do I run a pipeline on a cron?
kind: task
via_web: na
via_cli: na
via_python: available
via_api: na
via_config: na
ref_python: JobSettings
prereq: You need a pipeline in a module. See [Create a pipeline](/capabilities/build/knowledge-graph/creating-a-pipeline).
next:
  - /capabilities/build/pipelines/monitor-runs
  - /capabilities/build/workflows/schedule-a-workflow
  - /capabilities/build/modules/module-jobs
---

# Schedule a pipeline

A pipeline carries its triggers on the class, with `job = JobSettings(triggers=(...))`. Each tick starts `pipeline.<slug>` with the trigger's input as its parameters. The module publishes the schedule when it starts, and JetStream fires it on one replica of the module.

## Web UI

Not applicable. The System app's Jobs tab shows each pipeline's schedule and runs it by hand (**Run now**), but no screen sets a schedule: triggers are declared in code. Declare them with Python, then watch the runs in [Monitor runs](/capabilities/build/pipelines/monitor-runs).

## CLI

Not applicable. No `abi` command schedules a pipeline. Declare the triggers with Python.

## Python

### Set `job` on the class

```python title="src/catalog/pipelines/ItemsPipeline.py"
from datetime import timedelta

from naas_abi_sdk.jobs import Cron, JobSettings


class ItemsPipeline(Pipeline[ItemsPipelineParameters]):
    """Ingest the catalog's items into the knowledge graph."""

    job = JobSettings(
        triggers=(Cron("0 0 2 * * *", time_zone="UTC", input={"filter": "open"}),),
        timeout=timedelta(hours=1),
    )

    async def run(self, parameters: ItemsPipelineParameters) -> Graph: ...
```

- `JobSettings(triggers=(), timeout=None, max_attempts=1, max_concurrency=1)`. Keep `max_attempts=1` unless `run` is safe to repeat: a retry runs it again from the start.
- A `Cron` or `Every` input (default `{}`) is the run's parameters, and must validate against the parameters model, or the module refuses to start. An `OnEvent` run takes the event's `data` as its parameters.
- `timeout` cancels `run` and ends the run `TIMED_OUT`.
- `pipeline.<slug>` must not also be the name of a `@job` or a `@workflow` of the module.

More on triggers and startup errors: [Schedule a workflow](/capabilities/build/workflows/schedule-a-workflow?via=python).

### Pick the trigger

- `Cron("0 0 2 * * *", time_zone="UTC")`: six fields, seconds first, or an alias such as `@daily`. The aliases and time zones are on [Schedule a job](/capabilities/build/orchestrations/schedule-a-job?via=python).
- `Every("1h")` or `Every(timedelta(hours=1))`: a fixed interval, at least one second.
- `OnEvent(...)`: when an ABI event or a NATS message arrives. See [React to an event](/capabilities/build/orchestrations/react-to-an-event?via=python).

`triggers` takes up to 16 triggers. With the default `max_concurrency=1`, a run never overlaps the next. The trigger and option tables are on [Module jobs](/capabilities/build/modules/module-jobs).

### Restart the module

The module hosts the schedule when it starts. The pipeline then shows in the System app's Jobs tab with its next tick. Changing a trigger's input republishes that schedule only.

## REST API

Not applicable. No route sets a schedule. `POST /api/workflows/<module_id>/pipeline.<slug>/runs` starts one recorded run of the pipeline, so an outside scheduler can call it: see [Run a pipeline](/capabilities/build/pipelines/run-a-pipeline?via=api).

## Config

Not applicable. `config.yaml` has no per-pipeline key: triggers live on the class.

## Make it safe to run twice

Delivery is at least once: after a crash or a lost acknowledgement, the run can start again. A missed cron tick fires once when the broker comes back. Make the pipeline idempotent: write each entity under a stable IRI, so a second run adds no new triples.
