Reputation: 11
How to schedule one airflow DAG with 2 different scheduled interval with cron expression.
I want to combine below 2 intervals to schedule some airflow DAGs. schedule interval = '30 1,4,7,10,13,16,19,22 * * *' & '00 3,6,12,15,18,21,00 * * *'
I am trying to run the DAG with 90 mins cadence and trying to skip 9 AM run.
please let me know if this is possible by any means ?
I tried to schedule with */90 0-8,10-23 * * * but for some reason its not working and seems it expects 00-59 as past parameter expression
Upvotes: 0
Views: 965
Reputation: 436
There is no possible to have a two cron expression in the single DAG out of the box into the Airflow. As well as it not possible to have some expressions in minutes not in the range 0-59, at least croniter
, which is used in the Airflow, can't handle this case:
from datetime import datetime
from croniter import croniter
it = croniter("*/90 * * * *", datetime(2023, 1, 1))
print(it.get_next(datetime)) # 2023-01-01 01:00:00
print(it.get_next(datetime)) # 2023-01-01 02:00:00
print(it.get_next(datetime)) # 2023-01-01 02:00:00
However you always have an option to use Timetables which was introduced as part of AIP-39: Richer scheduler_interval in Airflow 2.2.
Some useful links which might help you achive your requirements:
Upvotes: 1