Skip to main content

Defining schedules

Defining basic schedules

The following examples demonstrate how to define some basic schedules.

This example demonstrates how to define a schedule using ScheduleDefinition that will run a job every day at midnight. While this example uses op jobs, the same approach will work with asset jobs.

@job
def my_job(): ...


basic_schedule = ScheduleDefinition(job=my_job, cron_schedule="0 0 * * *")
note

The cron_schedule argument accepts standard cron expressions. If your croniter dependency's version is >= 1.0.12, the argument will also accept the following:

  • @daily
  • @hourly
  • @monthly

Emitting log messages from schedule evaluation

This example demonstrates how to emit log messages from a schedule during its evaluation function. These logs will be visible in the UI when you inspect a tick in the schedule's tick history.

@schedule(job=my_job, cron_schedule="* * * * *")
def logs_then_skips(context):
context.log.info("Logging from a schedule!")
return SkipReason("Nothing to do")
note

Schedule logs are stored in your Dagster instance's compute log storage. You should ensure that your compute log storage is configured to view your schedule logs.