问题
I try to run a dynamic schedule_interval in Airflow like below. But it works only when I run the dag manually. Could you please help me say, if the dynamic schedule_interval could be a reason, why the dag does not run automatically or is there any other reasons for that?
if datetime.today().day == 1:
schedule_interval = '00 07 * * *'
else:
schedule_interval = '00 07 * * 1'
Thank you!
回答1:
You shouldn't set the schedule_interval
to be dynamic like this as it can lead to unexpected results (as you're seeing).
It looks like you're trying to run the DAG only on Mondays is that right? If that is the case then all you need to do is set the schedule_interval
to 00 07 * * 1
, you don't need the if
condition.
来源:https://stackoverflow.com/questions/59355145/dynamic-schedule-interval-in-airflow