Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I'm trying to add a scheduling feature to my web scraping application that will let the user schedule scraping jobs so he can, for instance, perform a job every Monday, or every 2 hours or stuff like that.

On one end, I could make a very simple scheduler that let you pick a specific date and time and pick a time interval that would indicate how often to execute the job starting at the specified date and time. So if, for instance, I pick Dec 31 at 2:00 pm and choose 1 day as my interval, the job would run every day at 2:00 pm starting Dec 31. But what if he wants to run the job every Saturday and Sunday, or three times a day on Sundays?

On the other end, I could embed some kind of scripting language that will let the user use any logic he wants, but this would be overkill for me and for the user. He doesn't need to run a job every day of the month that is prime number or anything like that.

So this is a common sense question, not a programming one. How would you implement this, or, do you know any similar kind of scheduling job in any other kind of application? I looked at the scheduler in my antivirus but this one is extremely plain and simple.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Why even do this at all? The operating system already has a scheduling service built-in (e.g. cron on *nix, Task Scheduler on Windows, etc). Just provide the ability to launch your process from the command-line launch and let the operating system take care of it.

If you like, you could build a UI in your application that interfaces with the operating system's built-in mechanism to provide the most common configurations, but for anything more complicated, scheduling is basically a solved problem.

share|improve this answer
Yea this makes sense. Only problem is this is a ClickOnce application and it is a pain to figure out the right path to execute and even more pain to pass parameters. –  Ahmet Dec 31 '11 at 4:53
@Ahmet: Ah, fair enough :-) –  Dean Harding Dec 31 '11 at 5:17
Ahmet: Better for you to have the pain than make your users feel the pain. This is a great answer, don't reinvent the wheel. –  JonnyBoats Dec 31 '11 at 5:18
If you're supporting XP and Vista/7, interfacing with the OS's Task Scheduler isn't exactly simple because of the vast difference between the two. @Ahmet: you mention using ClickOnce, so I assume the application is written in .Net? If so, you really should look at Quartz.Net –  qes Dec 31 '11 at 5:22
How about I include a console application with my ClickOnce installation that runs my ClickOnce app and on first run copy it to some normal directory such as Program Files\MyCompanyName. That Quartz.net looks interesting but a bit too much for what I need. –  Ahmet Dec 31 '11 at 6:16

I would think that something like the Windows Task Scheduler model would provide enough versatility for what your users are probably going to want. This is a task where I would take a YAGNI approach. Implement something basic and straightforward that covers most scenarios and then only work to include the exceptional cases on demand.

share|improve this answer

I would develop a UI for the most common scenarios. Once a day at a given time may be common. Or maybe continuously on a specific interval will be more common (for example, every half an hour).

If you want to offer more flexibility, I suggest allowing CRON expressions. No need for a custom scripting, CRON is it when it comes to scheduling. To allow ultimate flexibility, simply allow multiple CRON expressions.

One major advantage of CRON expressions, is that you will almost certainly have an scheduler implementation available to you that can accept them. There is Quartz for Java, Quartz.Net, and of course the cron daemon on any unix based system. I have used Quartz.Net with great success in the manner I described (simple config for daily and interval timing, with CRON used for more expressive timing)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.