I have a scheduler it will run every one minute. It works perfectly.
My code:
@Scheduled(cron = "${job.schedule.task.notifyServiceProvider:* */10 * * * *}") //0 59 23 * * ?
@SchedulerLock(name = "notifyServiceProvider()")
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
public void notifyServiceProvider() {
//my business logic here
}
Problem:
I want to pause this scheduler for weekends (every Saturday and Sunday)
How to pause scheduler only for Saturday and Sunday?
Feel free to give your feedback, it will helpful for me!
CodePudding user response:
You should edit your Cron expression to exclude weekend i.e. sixth field should be set to 1-5
or MON-FRI
.