Scheduling & Queues Examples
Examples for schedules, time zones, watched folders, queue assignment, global queues, and notifications.
Basic Scheduling
yaml
schedule: "5 4 * * *" # Run at 04:05 daily
steps:
- run: echo "Running scheduled job"Skip Redundant Runs
yaml
schedule: "0 */4 * * *" # Every 4 hours
skip_if_successful: true # Skip if already succeeded
steps:
- id: extract
run: echo "Extracting data"
- id: transform
run: echo "Transforming data"
depends: extract
- id: load
run: echo "Loading data"
depends: transformQueue Management
yaml
queue: "batch" # Assign to global queue for concurrency control
steps:
- run: echo "Processing data"Multiple Schedules
yaml
schedule:
- "0 9 * * MON-FRI" # Weekdays 9 AM
- "0 14 * * SAT,SUN" # Weekends 2 PM
steps:
- run: echo "Run on multiple times"Timezone
yaml
schedule: "CRON_TZ=America/New_York 0 9 * * *"
steps:
- run: echo "9AM New York"Watched Folder
yaml
watch:
path: ~/Downloads/invoices
pattern: "*.pdf"
interval: 30s
steps:
- id: read
action: chat.completion
with:
provider: anthropic
model: claude-sonnet-5
prompt: Read the invoice and give its number, date, and total.
files: ${WATCH_FILE}
output_schema:
type: object
properties:
number: {type: string}
date: {type: string}
total: {type: number}
required: [number]
- id: file
depends: read
action: file.move
with:
source: ${WATCH_FILE}
destination: ~/Documents/invoices/${steps.read.outputs.number}.pdf
create_dirs: trueStart/Stop/Restart Windows
yaml
schedule:
start: "0 8 * * *" # Start 8 AM
restart: "0 12 * * *" # Restart noon
stop: "0 18 * * *" # Stop 6 PM
restart_wait_sec: 60
steps:
- run: echo "Long-running service"Keep a Worker Running
yaml
restart_policy: always
restart_wait_sec: 5
hist_retention_runs: 100
steps:
- run: python3 worker.pyGlobal Queue Configuration
yaml
# Global queue config in ~/.config/dagu/config.yaml
queues:
enabled: true
config:
- name: "critical"
max_concurrency: 5
- name: "batch"
max_concurrency: 1Assign the queue in the DAG file:
yaml
queue: "critical" # Assign to queue for concurrency control
steps:
- run: echo "Processing critical task"Configure queues globally and assign DAGs using the queue field.
Email Notifications
yaml
mail_on:
failure: true
success: true
smtp:
host: smtp.gmail.com
port: "587"
username: "${env.SMTP_USER}"
password: "${env.SMTP_PASS}"
steps:
- run: echo "Running critical job"
mail_on_error: true
