Quartz.Net - 每 3 周周一、周二、周三

发布于 2024-11-25 08:06:18 字数 405 浏览 2 评论 0原文

我被 Quartz.NET cron 触发器困住了。 除了下面的场景之外,我能够实现所有场景。

  • 每 X 周的周一、周二、周三...

我设法做到了这一点

0 31 15 ? * MON#2 *

每隔两个星期一触发一次。

它可以与 0 31 15 一起使用吗? * 星期一#2,星期二#2,星期三#2 * ??

我尝试在 http://www.cronmaker.com 上测试它,但是它只向我显示星期一作为即将到来的日期。 我唯一的要求是保持简单 - 即。不超过一个触发器。

I'm stuck with Quartz.NET cron trigger.
I was able to imlpement all my scenarios apart the one below.

  • Every X weeks on Mon,Tue,Wed...

I managed to do this

0 31 15 ? * MON#2 *

which triggers every second Monday.

Would it work with 0 31 15 ? * MON#2,TUE#2,WED#2 * ??

I tried testing it on http://www.cronmaker.com however It only showed me Mondays as coming up dates.
My only requirement is to keep it simple - ie. no more than one trigger.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾`听者〃 2024-12-02 08:06:19

我同意布拉布斯特的观点。
我认为使用 Cron 表达式是不可能的。

Quartz.net 2.0 有一种名为CalendarIntervalTrigger 的新型触发器,可用于管理不同的间隔单位。
您可以在此处阅读更多信息。

更新

这是quartz.net 2.0 存储库<的链接/a>.

I agree with Brabster.
I don't think it is possible with a Cron Expression.

Quartz.net 2.0 has a new type of trigger called CalendarIntervalTrigger which can be used to manage different interval units.
You can read more here.

UPDATE:

Here's the link to the quartz.net 2.0 repository.

奢欲 2024-12-02 08:06:19

我使用了 Java Quartz 实现,假设它们是相似的,那么我认为不可能将您需要的内容表达为单个 CronTrigger。

在Java中,我们有DateIntervalTrigger,但我认为这也不能在单个触发器中满足您的需要。不幸的是,由于触发器不能在 API 本身中组合,我猜想可以表示为单个触发器的触发器的复杂性将会受到限制。

I've used the Java Quartz implementation, assuming they are similar then I don't think it's possible to express what you need as a single CronTrigger.

In Java we have the DateIntervalTrigger, but I don't think this could do what you need in a single trigger either. Unfortunately, as triggers can't be composed in the API itself,I guess there will be limits as to the complexity of triggers that can be expressed as a single trigger.

想挽留 2024-12-02 08:06:19

一种可能的解决方案是在一项作业上每周触发一个触发器,该触发器可以计算出是否已经过去 X 周并开始主要作业。

这可能违背你的“保持简单”的要求,但它会起作用。我必须实现类似的东西,以确保触发特定的作业实例而不是全新的实例。

您可能想看看这个问题,因为它问的几乎是同样的事情。

One possible solution would to have a trigger that fired every week attached to a job that figures out if X number of weeks has passed and starts the main job.

This might go against your 'keep it simple' requirement but it would be functional. I've had to implement something similar to ensure specific Job instances are triggered rather than a brand new instance.

You might want to look at this question as its asking pretty much the same thing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文