Cron表达式每45分钟执行一次

编程入门 行业动态 更新时间:2024-10-14 18:16:35
本文介绍了Cron表达式每45分钟执行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想要一个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分钟执行一次

本文发布于:2023-11-25 04:52:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628411.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   Cron

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!