views:

315

answers:

4

Hi,

I have this question from a client, to run some database scripts on a daily or biweekly basis, depending on the type of period. They have defined a 'busy' period and a 'quiet' period. They are using shared hosting for their applications and they can't add SQL Server jobs to their database.

What I want to do is create a windows service, which is configurable using a config file, containing the different periods and their intervals. This service is checking the current time and date versus the scheduled periods in the configuration file and will execute a sql server stored procedure once the interval matches

My question: Is there a better way to do this kind of scheduling without sql server or do you know if an existing, more generic (free) solution already exists?

[Edit] I can't use windows task scheduler since their quiet period is during winter and their busy period is during summer. With task scheduler I'd have to modify the scheduled tasks manually twice a year. That's now what I nor my client wants. [/Edit]

Thanks

+2  A: 

There's always the Windows Task Scheduler. Is there any reason why they would be allowed to install a service, but wouldn't be able to take advantage of the built-in scheduler?

Roger Lipscombe
Task scheduler would be nice if you could configure the dates, but you can only specify one interval. I don't want to manage different schedules on a yearly basis. I want to place a solution that works without maintenance...
Peter
Then run the SP from Task Scheduler every day. The SP can look at the date, decide that it's the quiet period, and exit immediately unless it's been more than 14 days since it last ran.
Roger Lipscombe
...or twice a week. I didn't know about that meaning (and I am a Brit). http://en.wiktionary.org/wiki/biweekly
Roger Lipscombe
sounds like a plan! I meant once every two weeks, thanks for the wiki link :)
Peter
+1  A: 

The Castle project has one (as part of Castle Components) that might get you most of the way there.

http://www.castleproject.org/

chrisb
http://www.castleproject.org/components/sitemap.html it's not there.I can see it on the main page but I don't think it's finished yet as there's no stable version nr listed.
Peter
+1  A: 

You could use "Scheduled Tasks" feature of windows to start some console application whenever it is required.

If you want to create your own scheduling solution, then I'd recommend to have a look at Quartz.NET, which offers the same flexibility as the windows task scheduler.

M4N
I'll check Quartz out, looks promising.
Peter
+1  A: 

Why not use the task scheduler and then every time your application gets started, it checks it's own schedule to work out whether or not it needs to do something.

So you could use the task scheduler to start your application every 15 minutes. When your application starts up it uses it's own configuration file to work out whether or not it needs to do something.

You could also use this to get your application to stop any currently running versions of your application to kill any long running tasks!

Nick R