问题
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.
回答1:
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.
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/6740198/quartz-net-every-3-weeks-on-mon-tue-wed