Complete the code to schedule a method to run every minute using a cron expression.
@Scheduled(cron = "[1]") public void runEveryMinute() { System.out.println("Running every minute"); }
The cron expression "0 * * * * *" means the method runs at the 0th second of every minute.
Complete the cron expression to schedule a task to run at 3:30 AM every day.
@Scheduled(cron = "[1]") public void runDailyAt330() { System.out.println("Running daily at 3:30 AM"); }
The cron expression "0 30 3 * * *" means at second 0, minute 30, hour 3 every day.
Fix the error in the cron expression to run a task every Monday at 8 AM.
@Scheduled(cron = "[1]") public void runEveryMondayAt8() { System.out.println("Running every Monday at 8 AM"); }
In Spring cron, '?' is used for day-of-month when specifying day-of-week. "0 0 8 ? * MON" runs at 8 AM every Monday.
Fill both blanks to schedule a task to run every 15 minutes between 9 AM and 5 PM on weekdays.
@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"); }
The expression "0 0/15 9-17 * * MON-FRI" means at second 0, every 15 minutes, hours 9 to 17, Monday to Friday.
Fill all three blanks to schedule a task to run at 10:15 PM on the last day of every month.
@Scheduled(cron = "[1] [2] [3] L * ?") public void runMonthlyLastDay() { System.out.println("Running at 10:15 PM on the last day of every month"); }
The cron expression "0 15 22 L * ?" means at second 0, minute 15, hour 22 (10 PM), on the last day (L) of every month.