Scheduling is one of the primary reasons for using an orchestrator such as Tracecat. Tracecat allows you to use schedules to automatically create new workflow runs.

A Schedule contains information that Tracecat uses to execute workflows for you automatically on a specified cadence. You can add multiple schedules to any workflow. The Tracecat scheduler (built on Temporal) periodically reviews every workflow and executes them according to their configued schedule.

Find the CLI reference for schedules here.

Creating a schedule

Schedules use ISO8601 duration strings to specify the schedule interval.

Assuming the following:

  1. You already have a workflow created
  2. This workflow takes inputs with field hello
  3. You’d like to schedule this workflow to run every 15 seconds

You can incoke the following command to achieve this like so:

tracecat schedule create <workflow_id> --every PT15S --data '{ "hello": "world" }'

The inputs passed here will be accessible from the TRIGGER context, and can be changed if you update the schedule.

If a schedules was successfully created, you should see a response like this:

{
    'owner_id': 'default-tracecat-user',
    'created_at': '2024-07-02T00:40:22.135461Z',
    'id': '<schedule_id>',
    'cron': None,
    'every': 'PT15S',
    'offset': None,
    'start_at': None,
    'end_at': None,
    'updated_at': '2024-07-02T00:42:06.962683Z',
    'status': 'online',
    'inputs': { "hello": "world"},
    'workflow_id': '<workflow_id>'
}

For convenience, you can put the input data in a json file:

inputs.json
{
    "hello": "world"
}

and invoke the command like so (note the filename prefixed with @):

tracecat schedule create <workflow_id> --every PT15S --data @inputs.json

Updating a schedule

You can pause a schedule (without deleting the underlying Temporal schedule) by running

traceat schedule update <schedule_id> --offline

and unpause it with

traceat schedule update <schedule_id> --online

To update the input data for the scheduled workflow run,

tracecat schedule update <schedule_id> --data @new_inputs.json