Skip to content

Writing Workflows ​

A workflow, or DAG, is a YAML file with a steps list. Each step runs a shell command or a built-in action, and depends sets the order. Start with one command, then add a schedule, parameters, retries, and handlers when the workflow needs them.

Start With One Command ​

Save this as hello.yaml:

yaml
steps:
  - run: echo "Hello from Dagu"

Run it:

bash
dagu start hello.yaml

That is a complete workflow. Workflow Basics grows it into a graph with parallel branches and explains what happens when a step fails.

How a Workflow Runs ​

Every trigger creates a DAG run: one execution of the file with its own run ID, step statuses, logs, and outputs.

The scheduler, Web UI, and REST API run inside the server (dagu start-all). dagu start runs a workflow directly from the command line.

Anatomy of a Workflow ​

Most workflows use a few top-level fields around steps:

yaml
description: Load yesterday's orders into the warehouse
labels: [etl, team=data]
schedule: "0 2 * * *"
working_dir: .

params:
  - name: date
    type: string
    default: "2026-12-01"

steps:
  - id: extract
    run: ./extract.sh "${params.date}"
    retry_policy:
      limit: 3
      interval_sec: 30

  - id: load
    depends: extract
    run: ./load.sh

handler_on:
  failure:
    run: ./notify-oncall.sh
PartFieldsRead
What runs and in which ordersteps, depends, typeWorkflow Basics
When it runsschedule, watch, calendarScheduling, Watched Folders
Inputsparams, env, dotenv, secretsParameters, Environment Variables, Secrets
Failure behaviorretry_policy, continue_on, timeout_sec, handler_onDurable Execution, Lifecycle Handlers
Where steps runworking_dir, container, tools, queueContainer, Tools, Queue Assignment
Organizationdescription, group, labelsLabels

The YAML Specification lists every field.

Develop and Run ​

CommandWhat it does
dagu validate etl.yamlCheck fields, types, and step references without running anything.
dagu dry etl.yamlSimulate a run without executing commands.
dagu test etl.test.yamlRun workflow tests with step actions mocked.
dagu start etl.yaml -- date=2026-12-02Run now, with parameter overrides after --.
dagu start --only load etl.yamlRun selected steps and record the rest as skipped.
dagu history etlList recent runs of a workflow.

To use the Web UI, start the server with your workflow folder and open http://localhost:8080:

bash
dagu start-all --dags .

Each workflow page shows the graph, live step status, logs, run history, and buttons to start, stop, and retry runs.

A finished etl-daily run in the Web UI: the step graph, run activity, and step timelineA finished etl-daily run in the Web UI: the step graph, run activity, and step timeline

Commands and Actions ​

run executes shell text. For work with structured inputs, set action and pass its inputs under with. Actions use the same depends, retries, conditions, statuses, and logs as commands.

yaml
steps:
  - id: fetch_rates
    action: http.request
    with:
      method: GET
      url: https://api.example.com/rates

  - id: report
    depends: fetch_rates
    action: docker.run
    with:
      image: python:3.13-slim
      command: python -c "print('rates fetched')"

Built-in Actions ​

NeedActionPage
Run a container or a Kubernetes jobdocker.run, kubernetes.runDocker, Kubernetes
Run commands or copy files over SSHssh.run, sftp.uploadSSH, SFTP
Call an APIhttp.requestHTTP
Query a databasepostgres.query, sqlite.querySQL
Transform JSON or datajq.filter, js.run, data.convertjq, JavaScript, Data
Move filess3.upload, file.copy, archive.extractS3, File, Archive
Branch to selected stepsrouter.routeRouter
Call another workflowdag.runSub-DAGs
Wait for a personhuman.taskHuman Tasks
Run a coding agent or an LLMharness.run, chat.completionHarness, LLM

The Actions section of the sidebar covers every action.

Container runtime access

Container actions need a Docker-compatible daemon. If Dagu itself runs in Docker, mount the host socket.

Find the Next Topic ​

When you want toRead
Pass parameters, outputs, and files between stepsData & Variables
Add conditions, loops, parallel iteration, or routingControl Flow
Split a workflow into reusable partsSub-DAGs
Skip holidays or run on business daysBusiness Calendars
Keep a workflow running like a serviceServices
Reuse unchanged file-producing stepsBuild Workflows
Send local scripts to distributed workersFile Dependencies
Test failure paths without running real commandsWorkflow Tests
Start from a copyable workflowExamples

Dagu is open source under the GNU General Public License v3.0.