Athena Wisdom
Athena Wisdom

Reputation: 6871

Prevent Disabled DAG from Running Instantly When Enabled

In Airflow 1.10.10, when a disabled DAG is enabled by pressing the button to change it's state from Off to On, the DAG will always run once before the next scheduled run time.

enter image description here

Is it possible to set a DAG to be enabled, but not make its first run until the next time it is scheduled to be run?

Currently, I need to quickly kill the DAG run after I toggle its state to be On.

Upvotes: 7

Views: 4296

Answers (2)

Afz Abd
Afz Abd

Reputation: 493

If it is daily task - set start date as below : This will prevent your DAG from running immediately after enabling.

default_args = {
    'start_date': airflow.utils.dates.days_ago(1) 
}

If it is a monthly task - set start date as below :

default_args = {
    'start_date': airflow.utils.dates.days_ago(30) 
}

Upvotes: 1

Oleg Pavliv
Oleg Pavliv

Reputation: 21192

You should set the start_date (which is a datetime) to value after now.

According to the docs

  • the first DAG Run is created based on the minimum start_date for the tasks in your DAG.
  • Subsequent DAG Runs are created by the scheduler process, based on your DAG’s schedule_interval, sequentially.

Upvotes: 2

Related Questions