Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz.Net - Every 3 weeks on Mon,Tue,Wed

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.

like image 465
Luke Avatar asked Jul 18 '11 22:07

Luke


People also ask

How does quartz Net work?

As per their website: Quartz.NET is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems. It's an old staple of many ASP.NET developers, used as a way of running background tasks on a timer, in a reliable, clustered, way.

What is Cron expression in C#?

Cron Schedule Examples : A Cron expression is designed to specify what date and time the scheduled task must be executed. Using Cron expressions, we can specify schedules such as the following. Run every minute every one hour. Run every hour, starting from the 15-minute mark of the hour.


2 Answers

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.

like image 172
LeftyX Avatar answered Sep 27 '22 23:09

LeftyX


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.

like image 38
brabster Avatar answered Sep 28 '22 00:09

brabster