Skip to main content

RUN WORKFLOWS ON A SCHEDULE

Prerequisites: Swamp installed, a repository with a workflow, swamp serve running. See Create and Run a Workflow if you need to create one first.

Add a trigger block to the workflow

Open your workflow YAML and add a trigger block with a schedule field containing a cron expression:

name: nightly-report
trigger:
  schedule: "0 0 * * *"
jobs:
  - name: main
    steps:
      - name: generate
        task:
          type: model_method
          modelIdOrName: my-reporter
          methodName: execute
          inputs:
            run: "echo Running nightly report"
        dependsOn: []

Validate the workflow

swamp workflow validate nightly-report

Validation confirms the trigger schema is valid along with the usual job and step checks.

Start swamp serve

Scheduled triggers only execute when the server is running:

swamp serve

The server picks up all workflows with trigger.schedule and registers them on startup.

Disable scheduling

To start the server without executing any scheduled workflows:

swamp serve --no-schedule

Common cron patterns

Pattern Schedule
0 * * * * Every hour
0 0 * * * Daily at midnight
0 9 * * 1-5 Weekdays at 9:00 AM
*/15 * * * * Every 15 minutes
0 0 * * 0 Weekly on Sunday at midnight

Pass inputs to scheduled runs

If the workflow defines an inputs schema, supply default values in the trigger block:

trigger:
  schedule: "0 0 * * *"
  inputs:
    env: "production"

Override a schedule without editing the workflow

To change the schedule of a workflow — yours or one from an extension — without modifying its YAML file, use swamp workflow trigger set:

swamp workflow trigger set nightly-report --schedule "0 3 * * *"

The override is written to serve.yaml and takes precedence over the workflow's built-in trigger. To include inputs:

swamp workflow trigger set nightly-report --schedule "0 3 * * *" --input env=production

To verify the effective schedule:

swamp workflow trigger get nightly-report

To remove the override and revert to the built-in trigger:

swamp workflow trigger remove nightly-report

Refer to the Workflows reference for the full flag set.