Quartz.Net cron 触发器每 45 分钟安排一次作业 [英] Quartz.Net cron trigger to schedule a job every 45 minutes

查看:56
本文介绍了Quartz.Net cron 触发器每 45 分钟安排一次作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用quartz.net 创建一个作业,该作业将在开始时间和结束时间之间每 45 分钟运行一次

I am trying to create a job with quartz.net which will run every 45 minutes between a start time and a end time

我尝试使用 cron tigger 创建这个

I have tried to create this with a cron tigger using

cronExpression = "0 0/45 8-5 * * ?";

cronExpression = "0 0/45 8-5 * * ?";

然而,这并不像我想要的那样工作.

however this is not working the way i want it to.

在查看了quartz.net 教程后,建议实现这样的工作需要使用两个触发器.

After looking at the quartz.net tutorials it is suggested to implement such a job would require using two triggers.

我对如何实现这个有点困惑,谁能就解决方案提出建议

I am a little confused on how to implement this, can anyone advise on a solution

推荐答案

Quartz.Net 教程大多基于 Quartz.Net v1.

Quartz.Net Tutorials are mostly based on Quartz.Net v1.

如果您使用的是 v2+,则可以使用以下触发器定义:

If you are using v2+, you can use the following trigger definition:

ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("trigger1", "group1")
    .WithDailyTimeIntervalSchedule(
        x => x.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(8, 0))
                 .EndingDailyAt(TimeOfDay.HourAndMinuteOfDay(11, 0))
                 .WithIntervalInMinutes(45))
    .Build();

这将创建一个触发器,在上午 8 点到上午 11 点之间每 45 分钟运行一次.

This will create a trigger, running every 45 minutes, between 8am and 11am.

这篇关于Quartz.Net cron 触发器每 45 分钟安排一次作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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