带有开始和结束时间的 Cron 表达式 [英] Cron expression with start and end time

查看:174
本文介绍了带有开始和结束时间的 Cron 表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试每天编写一个具有特定开始时间和结束时间的 cron 表达式.IE.每天 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 表达式.虽然第二个老太婆的表达有轻微的修改(突出显示的一个)

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 至上午 10:59 之间的每分钟)

0 15-59 10 * * * (Every minute between 10:15 AM and 10:59 AM)

0 * 11-16 * * *(每分钟,上午 11:00 至下午 04:59)

0 0-35 17 * * *(下午 05:00 至下午 05:35 之间的每分钟)

0 0-35 17 * * * (Every minute between 05:00 PM and 05:35 PM)

这篇关于带有开始和结束时间的 Cron 表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆