Schedules
schedule runs a workflow on a cron schedule. The scheduler that dagu start-all started in the setup checks every schedule and starts the runs.
The workflow
bash
curl -fsSLO https://docs.dagu.sh/tutorial/dags/tutorial-08-scheduling.yamlyaml
# Dagu tutorial, lesson 8: https://docs.dagu.sh/tutorial/scheduling
description: Runs every minute while the scheduler is up
type: graph
schedule: "* * * * *"
steps:
- id: snapshot
run: date "+Snapshot taken at %H:%M:%S"* * * * * is a cron expression for every minute. The five fields are minute, hour, day of month, month, and day of week.
| Schedule | Runs |
|---|---|
"0 2 * * *" | Every day at 2:00 |
"*/15 * * * *" | Every 15 minutes |
"0 9 * * MON-FRI" | Weekdays at 9:00 |
"@hourly" | At the start of every hour |
"CRON_TZ=Asia/Tokyo 0 9 * * *" | 9:00 in Tokyo, whatever the server's time zone |
Watch it run
snapshotrunSucceeded
Snapshot taken at 00:41:33
See it run on schedule
- Open
tutorial-08-schedulingin the Web UI and select the Cron launcher on the canvas. It lists the next three runs. - Wait for the next minute to start. A new run appears in Activity, started by the scheduler instead of by you.
Stop the schedule when you are done
This workflow runs every minute while Dagu is up. Delete tutorial-08-scheduling.yaml, or remove its schedule line, when you finish the lesson.
Try it
- Change the schedule to run every 2 minutes.
- Make it run only at 9:00 and 17:00 on weekdays.
Answers
schedule: "*/2 * * * *"schedule: "0 9,17 * * MON-FRI". A list of expressions also works:
yaml
type: graph
schedule:
- "0 9 * * MON-FRI"
- "0 17 * * MON-FRI"
steps:
- id: snapshot
run: date "+Snapshot taken at %H:%M:%S"
