0
0
Spring Bootframework~10 mins

Cron expressions for scheduling in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to schedule a method to run every minute using a cron expression.

Spring Boot
@Scheduled(cron = "[1]")
public void runEveryMinute() {
    System.out.println("Running every minute");
}
Drag options to blanks, or click blank then click option'
A"* * * * *"
B"*/5 * * * * ?"
C"0 0/1 * * * ?"
D"0 * * * * *"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 5 fields instead of 6 in the cron expression
Setting the wrong field for seconds
2fill in blank
medium

Complete the cron expression to schedule a task to run at 3:30 AM every day.

Spring Boot
@Scheduled(cron = "[1]")
public void runDailyAt330() {
    System.out.println("Running daily at 3:30 AM");
}
Drag options to blanks, or click blank then click option'
A"30 0 3 * * *"
B"0 30 3 * * *"
C"0 3 30 * * *"
D"0 30 15 * * *"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping minutes and hours
Using 24-hour format incorrectly
3fill in blank
hard

Fix the error in the cron expression to run a task every Monday at 8 AM.

Spring Boot
@Scheduled(cron = "[1]")
public void runEveryMondayAt8() {
    System.out.println("Running every Monday at 8 AM");
}
Drag options to blanks, or click blank then click option'
A"0 0 8 ? * MON"
B"0 0 8 * * MON"
C"0 0 8 * * 1"
D"0 0 8 ? * 2"
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' instead of '?' for day-of-month
Using numeric day-of-week incorrectly
4fill in blank
hard

Fill both blanks to schedule a task to run every 15 minutes between 9 AM and 5 PM on weekdays.

Spring Boot
@Scheduled(cron = "[1] [2] 9-17 * * MON-FRI")
public void runEvery15MinWeekdays() {
    System.out.println("Running every 15 minutes on weekdays between 9 AM and 5 PM");
}
Drag options to blanks, or click blank then click option'
A0
B0/15
C9-17
D*/15
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' for seconds causing multiple triggers
Incorrect hour range or day specification
5fill in blank
hard

Fill all three blanks to schedule a task to run at 10:15 PM on the last day of every month.

Spring Boot
@Scheduled(cron = "[1] [2] [3] L * ?")
public void runMonthlyLastDay() {
    System.out.println("Running at 10:15 PM on the last day of every month");
}
Drag options to blanks, or click blank then click option'
A0
B15
C22
D59
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong hour or minute values
Misplacing 'L' in the expression