Operate workflow schedules
A workflow schedule starts a workflow repeatedly on a cron schedule. Each time it matches, Diagrid starts a new execution of the workflow, a run, on the App ID that owns the schedule. The Schedules tab of the Workflows page in the Diagrid Console lists the schedules of every App ID in a project, with when each runs next and how its last run went, and lets you create, trigger and delete them.
The sections below cover these scenarios:
- A nightly report. Start the report workflow at 02:00 every day, and check in the morning how the run went, without a job or a cron container of your own.
- A run now. A report is needed before the next scheduled time. Trigger the schedule: the run gets the schedule's input and shows up as its last run.
- An outage. The app was down over a weekend. Decide whether each missed time gets its own run, or one run covers them all.
- Stopping a schedule. Delete it. The runs it already started carry on.
To create schedules from your code, see Schedule workflows. From the command line, use the diagrid workflow schedule commands shown on this page.
Schedules tab
The Schedules tab shows every schedule in the project, one row per schedule:
| Column | What it shows |
|---|---|
| App ID | The App ID that owns the schedule. |
| Name | The schedule's name, unique within its App ID. Every run's instance ID starts with it. |
| Schedule | The cron expression or interval, such as 0 0 2 * * * or @every 15m. See Schedule format. |
| Workflow | The workflow each run starts. |
| Next run | When the next run starts, unless the schedule is triggered sooner. Empty once the schedule has completed or failed. |
| Last run | When the last run started. It links to that run's execution details. |
| Status | How the last run went, or the schedule's own state once it has completed or failed. |
| Result | The start of the last run's output, or of its failure message. |
The list is read live from each App ID's runtime, so it shows the state of the schedules at the moment you open it. Select Refresh to read it again. When an App ID could not be read, for example because its runtime was unavailable, the tab says how many App IDs it could not read and shows the schedules of the others. When the project holds more schedules than the tab reads at once, it says that the list is cut short. A region that does not run workflow schedules yet shows a message instead of the list.
The same list from the CLI:
diagrid workflow schedule list
diagrid workflow schedule list --id reports --id billing
STATUS and RESULT are the console's Status and Result. Pass -o json or -o yaml for each schedule's full status, including the last run's instance ID and output.
Create a schedule from the console
Select Create schedule and fill in the form:
| Field | What it sets |
|---|---|
| App ID | The App ID that owns the schedule and hosts the workflow each run starts. |
| Name | 1 to 30 letters, digits and hyphens. |
| Workflow | The name of the workflow each run starts, as registered by the app. |
| Schedule | When runs start. See Schedule format. |
| Input | Optional JSON input every run is given. |
| First run | Optional. The time of the first run, in your local time. Without it, the first run is at the first time the schedule matches. |
| Expires | Optional. No run starts after this time, in your local time. The schedule then completes. |
| Repeats | Optional. The number of runs after which the schedule completes. |
| Skip missed runs | Start one run for the times the schedule missed while the app was down, rather than one run for each. See When the app is down. |
| Replace a schedule with the same name | Replace an existing schedule of that name, which resets its run count. Without it, a taken name is refused. |
A schedule created in the console starts its runs on the App ID that owns it. To start them on another App ID, create the schedule with the CLI's --target-id flag or from an SDK; see Options.
Creating a schedule needs the App ID's workflow worker to be connected, as starting a workflow does. Otherwise the request fails with 409 Conflict and the message App ID <app-id> has no connected workflow worker. Start the app and retry.
The same schedule from the CLI:
diagrid workflow schedule create nightly-report --id reports \
--workflow GenerateReport --schedule "0 0 2 * * *" --data '{"region":"eu"}'
Schedule actions
The action menu on each row offers:
| Action | What it does | Needs |
|---|---|---|
| Trigger now | Starts a run at once, with the schedule's input, without changing when the next scheduled run starts. The run counts towards the schedule's repeats. A schedule that has completed or failed cannot be triggered. | Update access to workflows |
| View runs | Opens the All workflow executions view filtered to the schedule's runs. | Read access to workflows |
| Delete | Stops and removes the schedule after you confirm. Runs it already started are not affected. | Delete access to workflows |
From the CLI:
diagrid workflow schedule get nightly-report --id reports
diagrid workflow schedule trigger nightly-report --id reports
diagrid workflow schedule delete nightly-report --id reports
trigger prints the instance ID of the run it started. delete asks for confirmation unless you pass --yes.
To change a schedule, create it again with Replace a schedule with the same name, or --overwrite on the CLI.
Find a schedule's runs
Each run is an ordinary workflow execution with the instance ID <schedule name>_<owner>_<time>, where the owner is a 6-character tag of the App ID that owns the schedule and the time is when the run was due, in UTC. A run started with Trigger now has the ID <schedule name>_<owner>_<time>_manual. View runs opens the executions view with the search set to the schedule name and _, so it lists these runs. When another App ID owns a schedule of the same name that targets this app, that schedule's runs match the search too. They carry a different owner tag, so narrow the search to <schedule name>_<owner>_; Find a schedule's runs shows how to work out the tag. Everything on Operate workflows applies to them: the execution details, the action menu, notifications and history archival.
When the app is down
A schedule never misses a time. If the app is down, or its workflow worker is not connected, when a time comes, Diagrid holds the schedule's timer until the worker connects again. Then every time the schedule missed starts its own run, one after another, and each run keeps the ID of the time it was due. A first run set in the past also starts a run for every time since it.
With Skip missed runs on, the same outage starts a single run, for 10:00, and the schedule carries on from the next time after now, 14:00. Choose it for work where one catch-up run is enough, such as a sync that always processes everything outstanding. Leave it off when every period must be processed on its own, such as a report per hour.
Runs count against the App ID's concurrent workflow limits like any other execution. A run that is due while the App ID is at its limit starts as soon as there is room.
The schedule's own execution
Each schedule is itself a small workflow execution that Diagrid runs for you, named dapr.internal.schedule with the instance ID dapr-internal-schedule-<schedule name>. It appears in the All workflow executions view, where its history shows each time it started a run, but not in the Workflows list, and it does not count against the project's workflow limits. To stop a schedule, delete it from the Schedules tab or with the CLI rather than acting on this execution. The workflow name and the instance ID prefix are reserved: starting or rerunning a workflow with either is refused.
See also
- Schedule workflows: create schedules from your SDK's workflow client, with the full options and status reference
- Operate workflows: the executions views, actions, notifications and archival that apply to every run
- Workflow access policies: what a target app must grant when a schedule starts its runs on another App ID
- Workflow CLI: the
diagrid workflowsubcommand reference
Was this page helpful?