Bird
Raised Fist0
Apache Airflowdevops~20 mins

Cron expressions in Airflow - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Airflow Cron Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the next execution time for this cron expression?
Given the cron expression 0 6 * * 1-5 in Airflow, what is the next scheduled run time if the current time is Monday 2024-06-03 05:00 UTC?
AMonday 2024-06-10 06:00 UTC
BTuesday 2024-06-04 06:00 UTC
CMonday 2024-06-03 06:00 UTC
DSunday 2024-06-02 06:00 UTC
Attempts:
2 left
💡 Hint
Remember that the cron runs at 6 AM on weekdays (Monday to Friday).
🧠 Conceptual
intermediate
1:30remaining
Understanding the meaning of a cron expression
What does the cron expression 30 23 15 * * mean in Airflow scheduling?
ARun at 11:30 AM on the 15th day of every month
BRun at 11:30 PM on the 15th day of every month
CRun every 15 minutes starting at 11:30 PM
DRun at 11:30 PM every day
Attempts:
2 left
💡 Hint
The first two numbers represent minutes and hours.
❓ Troubleshoot
advanced
2:00remaining
Why does this Airflow DAG not run as expected?
An Airflow DAG has the cron schedule 0 0 31 2 *. It never runs. Why?
AFebruary never has 31 days, so the schedule never matches
BThe timezone is not set, so the DAG runs at a different time
CAirflow does not support scheduling on specific days of the month
DThe cron expression syntax is invalid and causes an error
Attempts:
2 left
💡 Hint
Check if the date specified actually exists in the calendar.
✅ Best Practice
advanced
1:30remaining
Choosing a cron expression for daily midnight runs
Which cron expression is the best choice to schedule an Airflow DAG to run daily at midnight UTC?
A0 0 * * *
B0 24 * * *
C0 0 1 * *
D0 0 * * 0
Attempts:
2 left
💡 Hint
Midnight is hour 0, minute 0 every day.
🔀 Workflow
expert
2:30remaining
Order the steps to update an Airflow DAG's schedule using a cron expression
Put these steps in the correct order to update an Airflow DAG's schedule with a new cron expression.
A3,1,2,4
B2,1,3,4
C1,3,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Think about editing first, then testing, then deploying, then verifying.

Practice

(1/5)
1. What does the cron expression 0 12 * * * mean in Airflow scheduling?
easy
A. Run the task every day at 12:00 PM (noon)
B. Run the task every hour at minute 12
C. Run the task every 12 minutes
D. Run the task every day at midnight

Solution

  1. Step 1: Understand cron fields

    The expression has five parts: minute, hour, day of month, month, day of week. Here, 0 12 * * * means minute 0, hour 12, any day, any month, any weekday.
  2. Step 2: Interpret the time

    Minute 0 and hour 12 means the task runs once daily at 12:00 PM (noon).
  3. Final Answer:

    Run the task every day at 12:00 PM (noon) -> Option A
  4. Quick Check:

    Minute=0, Hour=12 means noon daily [OK]
Hint: Minute and hour fields show exact run time [OK]
Common Mistakes:
  • Confusing hour and minute positions
  • Thinking * means a specific time
  • Assuming 12 means midnight
2. Which of the following is the correct cron expression to run a task every 15 minutes in Airflow?
easy
A. */15 * * * *
B. 15 * * * *
C. 0 15 * * *
D. * 15 * * *

Solution

  1. Step 1: Understand the meaning of '*/15' in cron

    '*/15' in the minute field means every 15 minutes starting at 0.
  2. Step 2: Check other options

    15 * * * * runs at minute 15 every hour, 0 15 * * * runs at 3 PM daily, * 15 * * * is invalid because '*' in minute field with 15 in hour is not correct for every 15 minutes.
  3. Final Answer:

    */15 * * * * -> Option A
  4. Quick Check:

    */15 in minutes means every 15 minutes [OK]
Hint: Use '*/number' in minutes for periodic runs [OK]
Common Mistakes:
  • Using fixed minute instead of interval
  • Confusing hour and minute fields
  • Misplacing the slash '/' syntax
3. Given the cron expression 30 6 * * 1-5, when will the Airflow task run?
medium
A. At 6:30 AM every day
B. At 6:00 AM every weekday
C. At 6:30 PM Monday through Friday
D. At 6:30 AM Monday through Friday

Solution

  1. Step 1: Decode each cron field

    Minute=30, Hour=6, Day of month=any, Month=any, Day of week=1-5 (Monday to Friday).
  2. Step 2: Interpret the schedule

    The task runs at 6:30 AM on weekdays (Monday to Friday).
  3. Final Answer:

    At 6:30 AM Monday through Friday -> Option D
  4. Quick Check:

    Day of week 1-5 means weekdays [OK]
Hint: Day of week 1-5 means Monday to Friday [OK]
Common Mistakes:
  • Mixing AM and PM hours
  • Ignoring day of week range
  • Assuming day of month restricts schedule
4. You wrote the cron expression 60 24 * * * in Airflow to run a task daily. What is the problem?
medium
A. It runs every 60 minutes and 24 hours
B. It will run correctly at midnight
C. Minute 60 and hour 24 are invalid values
D. It runs only on the 60th day of the month

Solution

  1. Step 1: Check valid ranges for cron fields

    Minute must be 0-59, hour must be 0-23. Here, 60 and 24 are out of range.
  2. Step 2: Understand impact of invalid values

    Using invalid values causes syntax errors or the schedule will not run as expected.
  3. Final Answer:

    Minute 60 and hour 24 are invalid values -> Option C
  4. Quick Check:

    Minute max=59, Hour max=23 [OK]
Hint: Minutes max 59, hours max 23 in cron [OK]
Common Mistakes:
  • Using 60 for minutes instead of 0
  • Using 24 for hour instead of 0
  • Assuming cron accepts out-of-range values
5. You want to schedule an Airflow DAG to run at 11:45 PM on the last day of every month. Which cron expression should you use?
hard
A. 45 23 31 * *
B. 45 23 L * *
C. 45 23 * * 31
D. 45 23 * * L

Solution

  1. Step 1: Understand 'L' in cron expressions

    'L' means the last day of the month in the day-of-month field.
  2. Step 2: Check each option

    45 23 31 * * runs only on 31st (not all months have 31 days). 45 23 L * * uses 'L' in day-of-month field correctly. 45 23 * * 31 uses 31 in day-of-week field (invalid). 45 23 * * L uses 'L' in day-of-week field (invalid).
  3. Final Answer:

    45 23 L * * -> Option B
  4. Quick Check:

    'L' in day-of-month means last day [OK]
Hint: Use 'L' in day-of-month for last day of month [OK]
Common Mistakes:
  • Using 31 for all months (fails in shorter months)
  • Placing 'L' in wrong cron field
  • Confusing day-of-week and day-of-month fields
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard