Skip to content

Commit 236a4a1

Browse files
authored
Merge pull request #4909 from JoshVanL/dapr-scheduler
Adds documentation for `$ dapr scheduler`
2 parents dcdc00f + a527df0 commit 236a4a1

File tree

6 files changed

+432
-13
lines changed

6 files changed

+432
-13
lines changed

daprdocs/content/en/concepts/dapr-services/scheduler.md

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,93 @@ services:
115115
- ./dapr_scheduler/2:/var/run/dapr/scheduler
116116
```
117117
118-
## Back Up and Restore Scheduler Data
118+
## Managing jobs with the Dapr CLI
119119
120-
In production environments, it's recommended to perform periodic backups of this data at an interval that aligns with your recovery point objectives.
120+
Dapr provides a CLI for inspecting and managing all scheduled jobs, regardless of type.
121+
The CLI is the recommended way to view, back up, and delete jobs.
121122
122-
### Port Forward for Backup Operations
123+
There are several different types of jobs which Scheduler manages:
123124
124-
To perform backup and restore operations, you'll need to access the embedded etcd instance. This requires port forwarding to expose the etcd ports (port 2379).
125+
- `app/{app-id}/{job-name}`: Jobs created via the [Jobs API]({{% ref jobs_api %}})
126+
- `actor/{actor-type}/{actor-id}/{reminder-name}`: Actor reminder jobs created via the [Actor Reminders API]({{% ref "actors-timers-reminders#actor-reminders" %}})
127+
- `activity/{app-id}/{instance-id}::{generation-name}::{activity-index}`: Used internally for [Workflow Activity reminders]({{% ref "workflow-features-concepts.md#workflow-activities" %}})
128+
- `workflow/{app-id}/{instance-id}/{random-name}`: Used internally for [Workflows]({{% ref "workflow-overview.md" %}}).
125129

126-
#### Kubernetes Example
130+
Please see [here for how to manage specifically reminders]({{% ref "actors-timers-reminders#managing-reminders-with-the-cli" %}}) with the CLI.
127131

128-
Here's how to port forward and connect to the etcd instance:
132+
### List jobs
129133

130-
```shell
131-
kubectl port-forward svc/dapr-scheduler-server 2379:2379 -n dapr-system
134+
```bash
135+
dapr scheduler list
136+
```
137+
138+
Example output:
139+
140+
```bash
141+
NAME BEGIN COUNT LAST TRIGGER
142+
actor/myactortype/actorid1/test1 -3.89s 1 2025-10-03T16:58:55Z
143+
actor/myactortype/actorid2/test2 -3.89s 1 2025-10-03T16:58:55Z
144+
app/test-scheduler/test1 -3.89s 1 2025-10-03T16:58:55Z
145+
app/test-scheduler/test2 -3.89s 1 2025-10-03T16:58:55Z
146+
activity/test-scheduler/xyz1::0::1 -888.8ms 0
147+
activity/test-scheduler/xyz2::0::1 -888.8ms 0
148+
workflow/test-scheduler/abc1/timer-0-TVIQGkvu +50.0h 0
149+
workflow/test-scheduler/abc2/timer-0-OM2xqG9m +50.0h 0
150+
```
151+
152+
For more detail, use the wide output format:
153+
154+
```bash
155+
dapr scheduler list -o wide
156+
```
157+
158+
```yaml
159+
NAMESPACE NAME BEGIN EXPIRATION SCHEDULE DUE TIME TTL REPEATS COUNT LAST TRIGGER
160+
default actor/myactortype/actorid1/test1 2025-10-03T16:58:55Z @every 2h46m40s 2025-10-03T17:58:55+01:00 100 1 2025-10-03T16:58:55Z
161+
default actor/myactortype/actorid2/test2 2025-10-03T16:58:55Z @every 2h46m40s 2025-10-03T17:58:55+01:00 100 1 2025-10-03T16:58:55Z
162+
default app/test-scheduler/test1 2025-10-03T16:58:55Z @every 100m 2025-10-03T17:58:55+01:00 1234 1 2025-10-03T16:58:55Z
163+
default app/test-scheduler/test2 2025-10-03T16:58:55Z 2025-10-03T19:45:35Z @every 100m 2025-10-03T17:58:55+01:00 10000s 56788 1 2025-10-03T16:58:55Z
164+
default activity/test-scheduler/xyz1::0::1 2025-10-03T16:58:58Z 0s 0
165+
default activity/test-scheduler/xyz2::0::1 2025-10-03T16:58:58Z 0s 0
166+
default workflow/test-scheduler/abc1/timer-0-TVIQGkvu 2025-10-05T18:58:58Z 2025-10-05T18:58:58Z 0
167+
default workflow/test-scheduler/abc2/timer-0-OM2xqG9m 2025-10-05T18:58:58Z 2025-10-05T18:58:58Z 0
168+
```
169+
170+
### Get job details
171+
172+
```bash
173+
dapr scheduler get app/my-app/job1 -o yaml
132174
```
133175

134-
### Performing Backup and Restore
176+
### Delete jobs
135177

136-
Once you have access to the etcd ports, you can follow the [official etcd backup and restore documentation](https://etcd.io/docs/v3.5/op-guide/recovery/) to perform backup and restore operations. The process involves using standard etcd commands to create snapshots and restore from them.
178+
Delete one or more specific jobs:
179+
180+
```bash
181+
dapr scheduler delete app/my-app/job1 actor/MyActor/123/reminder1
182+
```
183+
184+
Bulk delete jobs with filters:
185+
186+
```bash
187+
dapr scheduler delete-all all
188+
dapr scheduler delete-all app/my-app
189+
dapr scheduler delete-all actor/MyActorType
190+
```
191+
192+
### Backup and restore jobs
193+
194+
Export all jobs to a file:
195+
196+
```bash
197+
dapr scheduler export -o backup.bin
198+
```
199+
200+
Re-import jobs from a backup file:
201+
202+
```bash
203+
dapr scheduler import -f backup.bin
204+
```
137205

138206
## Monitoring Scheduler's etcd Metrics
139207

@@ -155,7 +223,7 @@ For more information on running Dapr on Kubernetes, visit the [Kubernetes hostin
155223

156224
A number of Etcd flags are exposed on Scheduler which can be used to tune for your deployment use case.
157225

158-
### External Etcd database
226+
### External Etcd database
159227

160228
Scheduler can be configured to use an external Etcd database instead of the embedded one inside the Scheduler service replicas.
161229
It may be interesting to decouple the storage volume from the Scheduler StatefulSet or container, because of how the cluster or environment is administered or what storage backend is being used.
@@ -230,4 +298,5 @@ dapr_scheduler.etcdMaxSnapshots=10
230298

231299
## Related links
232300

233-
[Learn more about the Jobs API.]({{% ref jobs_api %}})
301+
- [Learn more about the Jobs API.]({{% ref jobs_api %}})
302+
- [Learn more about Actor Reminders.]{{% ref "actors-features-concepts#reminders" %}})

daprdocs/content/en/developing-applications/building-blocks/actors/actors-timers-reminders.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,66 @@ To use protobuf serialization for actor reminders on self-hosted, use the follow
187187
--max-api-level=20
188188
```
189189

190+
## Managing reminders with the CLI
191+
192+
Actor reminders are persisted in the Scheduler.
193+
You can manage them with the dapr scheduler CLI commands.
194+
195+
#### List actor reminders
196+
197+
```bash
198+
dapr scheduler list --filter actor
199+
NAME BEGIN COUNT LAST TRIGGER
200+
actor/MyActorType/actorid1/test1 -3.89s 1 2025-10-03T16:58:55Z
201+
actor/MyActorType/actorid2/test2 -3.89s 1 2025-10-03T16:58:55Z
202+
```
203+
204+
Get reminder details
205+
206+
```bash
207+
dapr scheduler get actor/MyActorType/actorid1/test1 -o yaml
208+
```
209+
210+
#### Delete reminders
211+
212+
Delete a single reminder:
213+
214+
```bash
215+
dapr scheduler delete actor/MyActorType/actorid1/test1
216+
```
217+
218+
Delete all reminders for a given actor type:
219+
220+
```bash
221+
dapr scheduler delete-all actor/MyActorType
222+
```
223+
224+
Delete all reminders for a specific actor instance:
225+
226+
```bash
227+
dapr scheduler delete-all actor/MyActorType/actorid1
228+
```
229+
230+
#### Backup and restore reminders
231+
232+
Export all reminders:
233+
234+
```bash
235+
dapr scheduler export -o reminders-backup.bin
236+
```
237+
238+
Restore from a backup file:
239+
240+
```bash
241+
dapr scheduler import -f reminders-backup.bin
242+
```
243+
244+
#### Summary
245+
246+
- Reminders are stored in the Dapr Scheduler, not in the app.
247+
- Create reminders via the Actors API
248+
- Manage existing reminders (list, get, delete, backup/restore) using the `dapr scheduler` CLI.
249+
190250
## Next steps
191251

192252
{{< button text="Configure actor runtime behavior >>" page="actors-runtime-config.md" >}}

daprdocs/content/en/developing-applications/building-blocks/jobs/jobs-features-concepts.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,60 @@ or the not-before time from which the schedule should take effect
119119
The `DueTime` and `Ttl` fields will reflect an RC3339 timestamp value reflective of the time zone provided when the job was
120120
originally scheduled. If no time zone was provided, these values indicate the time zone used by the server running
121121
Dapr.
122+
123+
### Managing jobs
124+
125+
While jobs are created via API calls, you can manage (list, inspect, delete, back up, and restore) jobs is by using the dapr scheduler CLI commands.
126+
127+
#### List jobs
128+
129+
```bash
130+
dapr scheduler list --filter app
131+
NAME BEGIN COUNT LAST TRIGGER
132+
app/my-app/my-job -3.89s 1 2025-10-03T16:58:55Z
133+
app/my-app/another-job -3.89s 1 2025-10-03T16:58:55Z
134+
```
135+
136+
```bash
137+
dapr scheduler list -o wide
138+
NAMESPACE NAME BEGIN EXPIRATION SCHEDULE DUE TIME TTL REPEATS COUNT LAST TRIGGER
139+
default app/my-app/my-job 2025-10-03T16:58:55Z @every 5s 2025-10-03T17:58:55+01:00 100 1 2025-10-03T16:58:55Z
140+
```
141+
142+
```bash
143+
dapr scheduler get app/my-app/my-job -o yaml
144+
```
145+
146+
#### Delete jobs
147+
148+
Delete a specific job:
149+
150+
```bash
151+
dapr scheduler delete app/my-app/my-job
152+
```
153+
154+
Delete all jobs for an app:
155+
156+
```bash
157+
dapr scheduler delete-all app/my-app
158+
```
159+
160+
#### Backup and restore jobs
161+
162+
Export all jobs:
163+
164+
```bash
165+
dapr scheduler export -o jobs-backup.bin
166+
```
167+
168+
Import them later:
169+
170+
```bash
171+
dapr scheduler import -f jobs-backup.bin
172+
```
173+
174+
#### Summary
175+
176+
- Use the Jobs API to create or update jobs from applications.
177+
- Use the dapr scheduler CLI to view, inspect, back up, or delete jobs.
178+
- Jobs are stored in the Dapr Scheduler, ensuring reliability across restarts and deployments.

daprdocs/content/en/developing-applications/building-blocks/workflow/howto-manage-workflow.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,67 @@ Now that you've [authored the workflow and its activities in your application]({
1010

1111
{{< tabpane text=true >}}
1212

13+
<!--CLI-->
14+
{{% tab "CLI" %}}
15+
Workflow reminders are stored in the Scheduler and can be managed using the dapr scheduler CLI.
16+
17+
#### List workflow reminders
18+
19+
```bash
20+
dapr scheduler list --filter workflow
21+
NAME BEGIN COUNT LAST TRIGGER
22+
workflow/my-app/instance1/timer-0-ABC123 +50.0h 0
23+
workflow/my-app/instance2/timer-0-XYZ789 +50.0h 0
24+
```
25+
26+
Get reminder details
27+
28+
```bash
29+
dapr scheduler get workflow/my-app/instance1/timer-0-ABC123 -o yaml
30+
```
31+
32+
#### Delete workflow reminders
33+
34+
Delete a single reminder:
35+
36+
```bash
37+
dapr scheduler delete workflow/my-app/instance1/timer-0-ABC123
38+
```
39+
40+
Delete all reminders for a given workflow app"
41+
42+
```bash
43+
dapr scheduler delete-all workflow/my-app
44+
```
45+
46+
Delete all reminders for a specific workflow instance:
47+
48+
```bash
49+
dapr scheduler delete-all workflow/my-app/instance1
50+
```
51+
52+
#### Backup and restore reminders
53+
54+
Export all reminders:
55+
56+
```bash
57+
dapr scheduler export -o workflow-reminders-backup.bin
58+
```
59+
60+
Restore from a backup file:
61+
62+
```bash
63+
dapr scheduler import -f workflow-reminders-backup.bin
64+
```
65+
66+
#### Summary
67+
68+
- Workflow reminders are persisted in the Dapr Scheduler.
69+
- Create workflow reminders via the Workflow API.
70+
- Manage reminders (list, get, delete, backup/restore) with the dapr scheduler CLI.
71+
72+
{{% /tab %}}
73+
1374
<!--Python-->
1475
{{% tab "Python" %}}
1576

@@ -356,7 +417,7 @@ To resume a workflow with an ID `12345678`, run:
356417
curl -X POST "http://localhost:3500/v1.0/workflows/dapr/12345678/resume"
357418
```
358419

359-
### Purge a workflow
420+
### Purge a workflow
360421

361422
The purge API can be used to permanently delete workflow metadata from the underlying state store, including any stored inputs, outputs, and workflow history records. This is often useful for implementing data retention policies and for freeing resources.
362423

daprdocs/content/en/getting-started/quickstarts/jobs-quickstart.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ dapr run -f .
8181
== APP - job-scheduler == Deleted job: BB-8
8282
```
8383

84+
You should eventually see the jobs being scheduled in scheduler:
85+
86+
```bash
87+
$ dapr scheduler list
88+
NAME TARGET BEGIN COUNT LAST TRIGGER
89+
C-3PO job +13.40s 0
90+
R2-D2 job +3.40s 0
91+
```
92+
8493
After 5 seconds, the terminal output should present the `R2-D2` job being processed:
8594

8695
```text
@@ -95,6 +104,13 @@ After 10 seconds, the terminal output should present the `C3-PO` job being proce
95104
== APP - job-service == Executing maintenance job: Memory Wipe
96105
```
97106

107+
The jobs will no longer be listed in the scheduler:
108+
109+
```bash
110+
$ dapr scheduler list
111+
NAME TARGET BEGIN COUNT LAST TRIGGER
112+
```
113+
98114
Once the process has completed, you can stop and clean up application processes with a single command.
99115

100116
```bash

0 commit comments

Comments
 (0)