Bird
0
0

You want to schedule a Spring Boot task to run every Monday at 8:30 AM, but only during the months of June, July, and August. Which cron expression correctly achieves this?

hard📝 Application Q15 of 15
Spring Boot - Async Processing
You want to schedule a Spring Boot task to run every Monday at 8:30 AM, but only during the months of June, July, and August. Which cron expression correctly achieves this?
A"0 30 8 ? 6,7,8 MON"
B"0 30 8 * 6-8 *"
C"0 30 8 ? 5-8 MON"
D"0 30 8 ? 6-8 1"
Step-by-Step Solution
Solution:
  1. Step 1: Understand cron fields needed

    Seconds=0, Minutes=30, Hours=8, Day=? (no specific day), Month=6,7,8 (June-Aug), Weekday=MON (Monday)
  2. Step 2: Check options for correct syntax

    "0 30 8 ? 6,7,8 MON" uses '?' for day, lists months as 6,7,8, and weekday as MON, which is correct.
  3. Final Answer:

    "0 30 8 ? 6,7,8 MON" -> Option A
  4. Quick Check:

    Use '?' for day, list months, specify MON weekday [OK]
Quick Trick: Use '?' for day when specifying weekday, list months with commas [OK]
Common Mistakes:
  • Using '*' for day and weekday together
  • Using range '-' instead of commas for months
  • Using numeric weekday instead of MON

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes