Reputation: 1235
I wonder if it is possible to write an cron expression with several conditions:
10:00
, 10:42
, 11:24
, 12:06
and etc.0
(e.g. 10:28
,10:29
), then cron first fire time should be 10:30
. So it means that first fire time should have "round" minutes.I hope that you understand these conditions. Is it possible to describe them with quartz cron?
Upvotes: 2
Views: 1972
Reputation: 209
You can use job trigger like described below in Quartz.net 3.0:
var jobTrigger = TriggerBuilder.Create()
.StartNow()
.WithSimpleSchedule(s => s
.WithIntervalInMinutes(42)
.RepeatForever())
.Build();
And you can restart app at first round time, so it will fire first time at the same time only.
Upvotes: 1
Reputation: 2115
It is not possible, see for explanation and similar issue: Quartz.net - Repeat on day n, of every m months?
it is also not possible by Cron expressions. To do this, you would need to apply some complex logic, use some operator that is not present in evaluators. Why do you need this? Would you like to combine those 2 requirements and create single complex pattern?
Upvotes: 0
Reputation: 314
I usually use http://www.cronmaker.com/ to generate my cron expressions. And if you try the every 42 mins option you'll get the following expression: " 0 0/42 * 1/1 * ? *". As for the "round" minutes thing, you can try this when building your trigger:
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity(JobTrigger, JobGroup)
.WithCronSchedule(CroneExpression)
.StartAt(new DateTimeOffset(DateTime.Now,
TimeSpan.FromMinutes(DateTime.Now.Minute % 10)))
.Build();
Upvotes: 0