Search code examples
airflowairflow-scheduler

Airflow DAG Scheduling for end of month


I want to run a schedule on Airflow (v1.9.0).
My DAG needs to run at every end of month, but I don't know how to write the settings.

my_dag = DAG(dag_id=DAG_ID,
             catchup=False,
             default_args=default_args,
             schedule_interval='30 0 31 * *',
             start_date=datetime(2019, 7, 1))

But this won't work in a month where there's no 31st, right?
How can I write a schedule_interval to run at every end of the month?


Solution

  • You can do this by putting L in the month position of your schedule_interval cron expression.

    schedule_interval='59 23 L * *' # 23:59 on the last day of the month