Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to create a cron schedule that repeats every 2 weeks on Mondays. Cronmaker.com doesn't have the cron expression for this. Please advice.
Posted
Comments
ZurdoDev 25-Mar-15 7:53am    
Refer here http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
ZurdoDev 25-Mar-15 7:54am    
I'm not sure you can do it that way. If not, you can always do it without CRON.
mayooran99 25-Mar-15 8:02am    
without CRON, I can do this.

var trigger = TriggerBuilder.Create()
.StartAt(new DateTime(2012, 11, 19, 12, 0, 0).ToUniversalTime())
.WithCalendarIntervalSchedule(x => x.WithIntervalInWeeks(2))
.Build();

by where do I specify its on MOnday?
ZurdoDev 25-Mar-15 8:09am    
If your StartAt date is a Monday then every 2 weeks would always be Monday, right?
mayooran99 25-Mar-15 8:11am    
No its like, I start it on Tuesday and I want it thereafter to fire on every 2 weeks on mondays

As discussed in comments, I don't believe CRON can represent what you want. If you want it to start today and then do every 2 weeks on a Monday I would suggest one option would be to 2 triggers then. There is a DailyTimeIntervalScheduleBuilder but I don't think it lets you have a weekly interval.

1 trigger can be to run now and then one to start the following Monday and then repeat every 2 weeks.
 
Share this answer
 
Nearest Thursday and Friday at 1,40am... Then, two weeks (336h) after , again:
0 40 1/336 ? * THU,FRI

But "Quartz Cron" does not support/like it as increment is bigger than 24h.
 
Share this answer
 
Comments
OriginalGriff 3-Mar-23 1:46am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 8 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more! And I don't see any relevance in your reply anyway ...

Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900