Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 341
manomechi Avatar asked Mar 04 '23 19:03

manomechi


1 Answers

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
like image 80
Ian Bender Avatar answered Mar 06 '23 20:03

Ian Bender