What is the best way to specify the timing of recurring tasks or tasks?

I am looking for a way to efficiently set recurring execution times for a job without having to write explicit execution times in the data store. In other words, instead of saying "job x next run at 13.00pm on 12/11/08" and then to update the runtime next week after the job is done, I want to say that "job x runs at 13:00 every Thursday". I need to specify a repetition range from a few minutes to once a month. My guess is that the shorter the repetition period, the more difficult it gets. Any ideas?

Note. I'm not looking for scheduling engine advice... I cannot use Windows Scheduler, Cron, or create a Windows service (I have no choice but to use a background thread in ASP.NET).

+1


source to share


3 answers


I've seen widely used cron expressions for this, it can work well as an internal representation format.



+3


source


I agree with kamal that Cron is probably the simplest solution for setting up the scheduler. It's very flexible - you can set it up to do anything (within reason).



I've used Quartz.NET for scheduling in the past. It provides a CronTrigger - see the tutorial. You can create a thread in your web application that launches the Quartz scheduler.

+1


source


I have implemented some unattended services (Windows services written in C #) using cron to manage scheduling. The template is powerful and flexible. We can create schedules anytime we want using just a cron expression. I may be wrong, but the only graph that doesn't seem to cover the crown is if we want the last day of the month, but this was never required for all services.

I copied the cron algorithm from an article on the web (open source Atif Aziz) and implemented utilities in my class, working fine for years.

Read more in the blog: CronTab syntax analysis algorithm

Hooray!

Roberto

0


source







All Articles