Customizing a schedule's execution timezone
You can scaffold schedules from the command line by running dg scaffold defs dagster.schedule <path/to/schedule_file.py>. For more information, see the dg CLI docs.
Schedules that don't have a set timezone will, by default, execute in UTC. In this guide, you will learn to:
- Set custom timezones on schedule definitions
- Set custom timezones on partitioned jobs
- Account for the impact of Daylight Savings Time on schedule execution times
This guide assumes familiarity with:
- Schedules
- Jobs, either asset or op-based
- Partitions
Setting timezones on schedule definitions
Using the execution_timezone parameter allows you to specify a timezone for the schedule on the following objects:
This parameter accepts any tz timezone. For example, the following schedule will execute every day at 9:00 AM in US Pacific time (America/Los_Angeles):
my_timezone_schedule = dg.ScheduleDefinition(
name="my_timezone_schedule",
target="*",
cron_schedule="0 9 * * *",
execution_timezone="America/Los_Angeles",
)
Setting timezones on partitioned jobs
Schedules constructed from partitioned jobs execute in the timezone defined on the partition's config. Partitions definitions have a timezone parameter, which accepts any tz timezone.
For example, the following partition uses the US Pacific (America/Los_Angeles) timezone:
from dagster import DailyPartitionsDefinition
daily_partition = DailyPartitionsDefinition(
start_date="2024-05-20", timezone="America/Los_Angeles"
)
Execution times and Daylight Savings Time
When Daylight Savings Time (DST) begins and ends, there may be some impact on your schedules' execution times.