I need set up spring scheduled time to be executed every 15 minutes from 5 p.m till 8 a.m, how to specify such expression? And also I\'d like task be executed on we
On the safe site you need to add the time-zone of the respective country
// 0/15 -> Every 15 minutes on the clock
// 17-20 -> Between 5pm and 8pm
@Scheduled(cron="0 0/15 17-20 * * ?",zone="Your time zone")
Ex:--
@Scheduled(cron="0 0/15 17-20 * * ?",zone="Asia/Calcutta")
public void yourJob(){
..........
..........your code
..........
}
Below is some basic configuration corn expression
The pattern is a list of six single space-separated fields: representing second, minute, hour, day, month, weekday. Month and weekday names can be given as the first three letters of the English names.
Example patterns:
"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 6,19 * * *" = 6:00 AM and 7:00 PM every day.
"0 0/30 8-10 * * *" = 8:00, 8:30, 9:00, 9:30, 10:00 and 10:30 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