[英]Inverted weekday range in cron for @Scheduled?
I want to execute a task at specific hours from Friday till Monday. 我想在星期五至星期一的特定时间执行任务。
Having specified like that 这样指定
@Scheduled(cron = "0 0/30 15-23 * * FRI-MON", zone = "CET")
I receive an exception of type IllegalStateException
我收到
IllegalStateException
类型的异常
Invalid inverted range: '5-1' in expression "0 0/30 15-23 * * FRI-MON"
My workaround is currently to specify those days by separating them with commas. 目前,我的解决方法是通过用逗号分隔来指定那些日子。
@Scheduled(cron = "0 0/30 15-23 * * FRI,SAT,SUN,MON", zone = "CET")
I would like to be able to write it shorter as an inverted range though. 我希望能够将它写得更短些,但它是一个反向范围。 Is there any possibility to do so?
有可能这样做吗? I could not find anything in the documentation.
我在文档中找不到任何内容。
You can try "0 0/30 15-23 * * 1,5-7" if that's short enough. 如果足够短,可以尝试“ 0 0/30 15-23 * * 1,5-7”。 (0 as well as 7 maps to Sunday).
(0和7映射到星期日)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.