Subchapter 2.13
references/automation/schedules.mdMarkdown4 KBView on GitHub
Basic schedule patterns are covered in the main SKILL.md Quick Reference. This reference covers advanced schedule configuration and partitioned job automation.
A schedule executes a job at specified times using cron expressions. See SKILL.md for the basic pattern.
import dagster as dg
daily_job = dg.define_asset_job("daily_job", selection="*")
daily_schedule = dg.ScheduleDefinition(
job=daily_job,
cron_schedule="0 0 * * *", # Midnight UTC
)Schedules default to UTC. Specify a different timezone with execution_timezone:
daily_schedule = dg.ScheduleDefinition(
job=daily_refresh_job,
cron_schedule="0 9 * * *", # 9 AM
execution_timezone="America/Los_Angeles",
)Timezone string format: Use IANA timezone database names like "America/New_York", "Europe/London", or "Asia/Tokyo".
Daylight saving time: Dagster handles DST transitions automatically based on the specified timezone.
For partitioned assets or jobs, use build_schedule_from_partitioned_job to automatically create a schedule matching the partition cadence:
@dg.asset(partitions_def=dg.DailyPartitionsDefinition(start_date="2024-01-01"))
def daily_asset(context: dg.AssetExecutionContext):
partition_date = context.partition_key
# Process data for this partition
...
partitioned_job = dg.define_asset_job(name="daily_partitioned_job", selection=[daily_asset])
# Schedule automatically inherits daily cadence and timezone from partition definition
schedule = dg.build_schedule_from_partitioned_job(partitioned_job)How it works: The schedule’s cron expression is derived from the PartitionsDefinition:
DailyPartitionsDefinition → daily cron scheduleWeeklyPartitionsDefinition → weekly cron scheduleMonthlyPartitionsDefinition → monthly cron scheduleHourlyPartitionsDefinition → hourly cron scheduleEach schedule run materializes the partition corresponding to the schedule time.
Common cron patterns for schedules:
| Cron Expression | Description |
|---|---|
0 * * * * | Every hour |
0 0 * * * | Daily at midnight |
0 9 * * * | Daily at 9 AM |
0 0 * * 1 | Weekly on Monday |
0 0 1 * * | Monthly on the 1st |
0 0 1 1 * | Yearly on January 1st |
*/15 * * * * | Every 15 minutes |
0 9-17 * * 1-5 | Hourly, 9 AM-5 PM, weekdays |
Cron format: minute hour day_of_month month day_of_week
schedule = dg.ScheduleDefinition(
job=my_job,
cron_schedule="0 0 * * *",
execution_timezone="UTC",
default_status=dg.DefaultScheduleStatus.RUNNING, # Start enabled
description="Daily data refresh for analytics",
tags={"team": "data-eng", "priority": "high"},
)Key parameters:
default_status: Set to DefaultScheduleStatus.RUNNING to enable schedule automatically when deployed (default is STOPPED)description: Human-readable description shown in the Dagster UItags: Metadata tags for organization and filteringUse schedules when:
Prefer declarative automation when: