我想要一个cron表达式,每45分钟触发一次。
I want a cron expression which fires every 45 minutes.
根据文档,我创建了 0 0/45 * *?表达式。
According to the documentation, I have created this 0 0/45 * * * ? expression.
但它会以12:00,12:45,13:00,13:45,14:00的模式被解雇。
But it is fired in a pattern like 12:00, 12:45, 13:00, 13:45, 14:00.
但我期望和想要的是在12:00,12:45,13:30,14:15被解雇。
But what I expect and want is to be fired at 12:00, 12:45, 13:30, 14:15.
我缺少什么?
推荐答案Cron不是为了解决这些问题。它定义确切的日期和时间,触发器必须触发,而不是间隔。使用简单的计划:
Cron is not meant to solve such problems. It defines the exact date and times, when a trigger must be fired, not intervals. Use a simple schedule instead:
TriggerBuilder.Create() .StartAt(startDate) .WithSimpleSchedule( simpleScheduleBuilder => simpleScheduleBuilder.WithIntervalInMinutes(45)) .Build();编辑:这是一个简单的时间表,或多个cron触发器(Quartz作业可以有多个触发器):
It's either a simple schedule as above, or multiple cron triggers (Quartz jobs can have multiple triggers):
0 0/45 12/3 * * ? # 12:00, 12:45, 15:00, 15:45, ... 0 30 13/3 * * ? # 13:30, 16:30, ... 0 15 14/3 * * ? # 14:15, 17:15, ...更多推荐
Cron表达式每45分钟执行一次
发布评论