具有开始时间和结束时间的Cron表达式 [英] Cron expression with start and end time
问题描述
我正在尝试编写每天都有特定开始时间和结束时间的cron表达式。即
从每天的10:15到17:35每分钟
I am trying to write an cron expression with a specific start time and end time everyday. i.e. every minute from 10:15 to 17:35 everyday
一个可能的解决方案是编写3种不同的cron表达式,如下所示:
One possible solution for this is writing 3 different cron expressions like this:
0 15-59 10 * * *
0 * 11-17 * * *
0 0-35 17 * * *
有没有可能在单个cron表达式中编写它?
Is there any possible way to write this in one single cron expression ?
推荐答案
没有其他方法可以使用单个crone表达式来实现它,而是为特定的startDate和endDate指定多个crone表达式。
虽然第二个crone表达式有一些修改(突出显示的一个)
There is no other way to achieve it using single crone expression but to specify multiple crone expressions for specific startDate and endDate. There is a slight modification in second crone expression though (highlighted one)
0 15-59 10 * * *(每10:15 AM到10:59 AM之间的每分钟)
0 15-59 10 * * * (Every minute between 10:15 AM and 10:59 AM)
0 * 11-16 * * *(每分钟,从11:00 AM到04:59 PM)
0 0-35 17 * * *(05:00 PM和05:35 PM之间的每分钟)
0 0-35 17 * * * (Every minute between 05:00 PM and 05:35 PM)
这篇关于具有开始时间和结束时间的Cron表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!