春季启动调度程序暂停
我有一个调度程序,它将每分钟运行一次。它可以很好地工作。
我的代码:
@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
}
问题:
我想在周末(每个星期六和周日)中暂停此调度程序,
如何仅在星期六和周日暂停调度程序?
随时提供反馈,这对我有帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该编辑 cron表达式排除周末,即应将第六个字段设置为
1-5
或Mon-Fri
。You should edit your Cron expression to exclude weekend i.e. sixth field should be set to
1-5
orMON-FRI
.