I need the cron expression that runs every 15min from 5am to 6am(including). When i am using '0 */15 5 * * ?' it runs from 5 but ends at 5:45.I want to include 6am as well.Any inputs will be helpful.
CodePudding user response:
Below you can find the example patterns from the spring forum:
- "0 0 * * * *" = the top of every hour of every day.
- "*/10 * * * * *" = every ten seconds.
- "0 0 8-10 * * *" = 8, 9 and 10 o'clock of every day.
- "0 0 8,10 * * *" = 8 and 10 o'clock of every day.
- "0 0/30 8-10 * * *" = 8:00, 8:30, 9:00, 9:30, 10:00 and 10:30 o'clock every day.
- "0 0 9-17 * * MON-FRI" = on the hour nine-to-five weekdays
- "0 0 0 25 12 ?" = every Christmas Day at midnight Cron expression is represented by six fields:
second, minute, hour, day of the month, month, day(s) of week
You need to schedule it with two lines
"0 0/15 5 * * *"
"0 0 6 * * *"
EDIT:
Example
@Scheduled(cron = "0 0/15 5 * * *")
@Scheduled(cron = "0 0 6 * * *")
public String execute() {
return "success";
}
