Airflow Cron Expression

broken image


  1. Dag Schedule Interval
  2. Airflow Cron Expression Plus
  3. Airflow Retry
  4. Airflow Schedule Interval Format

It may be possible if you make some customizations of your Airflow instance or use a plugin. If you are quite desperate, you may try to copy the cron expression to and check the execution date using that website. In this article, I will use something way simpler. All we need is the airflow command-line interface. The Airflow scheduler is designed to run as a persistent service in an Airflow production environment. To kick it off, all you need to do is execute the airflow scheduler command. It uses the configuration specified in airflow.cfg. The scheduler uses the configured Executor to run tasks that are ready. To start a scheduler, simply run the command. Scheduleinterval is defined as a DAG argument, which can be passed a cron expression as a str, a datetime.timedelta object, or one of of the following cron 'presets'. You can use an online editor for CRON expressions such as Crontab guru. An Airflow DAG with a.

This article is a part of my '100 data engineering tutorials in 100 days' challenge. (98/100)

I was surprised when I saw the DayOfWeekSensor in Airflow. Why is it here? Is it for the people who don't know how to choose a day of the week in the CRON expression?

In the documentation, we see an example which looks like this:

It is strange. We can get the same result using a cron expression, for example: 0 10 * * 6-7.

Dag Schedule Interval

So what are the possible use-case for the DayOfWeekSensor? I found two of them:

Airflow daily
Airflow crontab
Airflow Cron Expression

First, putting a sensor that waits for a specific day of the week is more explicit than tweaking the cron expression, so it is easier to spot that this DAG runs only on weekends.

Airflow Cron Expression

Second, in the case of DAGs that run for multiple days, we may have a DAG that starts on Monday, runs some code for a few hours, and needs to wait until Wednesday to do something else. Still, for whatever reason, we don't want to split that DAG into two separate DAGs running on different days.

Airflow Cron Expression Plus

To be honest, I have no idea what is the usage of this sensor. Do you know? Let me know.

Airflow Retry

You may also like

Remember to share on social media!
If you like this text, please share it on Facebook/Twitter/LinkedIn/Reddit or other social media.

Expression

First, putting a sensor that waits for a specific day of the week is more explicit than tweaking the cron expression, so it is easier to spot that this DAG runs only on weekends.

Second, in the case of DAGs that run for multiple days, we may have a DAG that starts on Monday, runs some code for a few hours, and needs to wait until Wednesday to do something else. Still, for whatever reason, we don't want to split that DAG into two separate DAGs running on different days.

Airflow Cron Expression Plus

To be honest, I have no idea what is the usage of this sensor. Do you know? Let me know.

Airflow Retry

You may also like

Remember to share on social media!
If you like this text, please share it on Facebook/Twitter/LinkedIn/Reddit or other social media.

If you want to contact me, send me a message on LinkedIn or Twitter.

Airflow Schedule Interval Format

Would you like to have a call and talk? Please schedule a meeting using this link.





broken image