moirK
moirK

Reputation: 681

Unable to make Airflow DAG run at a specific time every day

I am trying to schedule an Airflow DAG but unable to do so successfully. I have a valid start date. I want to schedule it to run every morning at 5:30 AM but I have had to manually trigger it the last couple of days.

Here´s what my schedule interval looks like: schedule_interval='30 5 0 0 0'. I have also tried it with a different syntax like this: schedule_interval='30 5 * * *', but couldn´t make it work. Below is my complete code:

default_dag_args = {
    'start_date': datetime.datetime(2020, 9, 15),
}

with models.DAG(
        'data_dump',
        schedule_interval='30 5 0 0 0',
        default_args=default_dag_args) as dag:
  
    hello = bash_operator.BashOperator(
            task_id='hello',
            bash_command='echo Hello.')

    goodbye_bash = bash_operator.BashOperator(
        task_id='bye',
        bash_command='echo Goodbye.')

    hello >> goodbye_bash

I am starting to wonder, does schedule_interval have anything to do with time zones. Currently I am using Airflow with Cloud Composer environment set in europe-west1-b.

I need help in figuring out what´s wrong with my code and how to schedule a DAG correctly and would appreciate your response. Thanks in advance.

Upvotes: 1

Views: 680

Answers (1)

kaxil
kaxil

Reputation: 18844

@philipp-johannis is correct, 30 5 * * * is the correct scheduler_interval.

You can test with an older start_date as follows:

with models.DAG(
        'data_dump',
        schedule_interval='30 5 0 0 0',
        start_date=datetime.datetime(2020, 9, 1)) as dag:

Upvotes: 1

Related Questions