Paolo's Notes

BA by day, sleepy coder by night...

Windows cron

What would be the best way to execute an .NET executable every, say, 3 hours? And how should I build it, as an .aspx with no output? Suggestions are welcome :)
Posted: Oct 20 2003, 10:39 AM by Pmarcucci | with 9 comment(s)
Filed under:


Oddur Magnusson said:

Windows cron = Scheduled Tasks
# October 20, 2003 1:46 PM

Dave said:

I'm curious, why even think of an .aspx? That's a webpage right? Why not at least do your basic Sub Main() module type WinForm - whatever the equivalent is in .NET?
# October 20, 2003 1:49 PM

Addy Santo said:

1. There is a windows scheduler which is specifically designed for the scenario you described.

2. A scheduled task is automated and usually has no UI. So why would you want to require the overhead of going over HTTP through IIS? A console app is as slim as they come and should fit your requirements.

3. If you really need web access (does your task call across servers?) then expose a web service instead of a web page - you get more flexibility with less overhead. AND you can easily reuse that functionality later in other apps.

# October 20, 2003 2:24 PM

Jeff Gonzalez said:

If you really wanted an aspx page that bad, you could use scheduled tasks and start an instance of iexplore.exe and pass the address as a parameter.

I would agree with the other commentor's though, that a console application would provide a much better solution than an aspx page.
# October 20, 2003 2:36 PM

Paolo Marcucci said:

I wasn't in deep love with the aspx idea, it was just something that popped in my mind when I was writing the post :)

But yeah, a console app would definitely be perfect. Thanks guys!
# October 20, 2003 4:06 PM

Christopher said:

What about a Windows Service w/ a timer class in it? That seems like a perfect fit - it runs in the background, and you can set the timer to kick off a job every three hours as you indicated you wanted to do.

just my $0.02
# October 20, 2003 4:33 PM

Wallym said:

Windows Service and a timer. Runs GREAT.

# October 20, 2003 4:36 PM

Paolo Marcucci said:

I am a bit wary of the Service idea because this app will have to work between tonight (if!) and next friday, 31st. So I didn't want to add services and stuff to a remote server just for 15 days. Is it possible to develop and test as a CLI and then convert it to a service? (darn, I sound like a newbie :) )
# October 20, 2003 4:44 PM

Dave Burke said:

Console Apps are easier to write than web apps. Then use the schedule. I've been doing this for a LONG time and had absolutely NO PROBLEMS. And like I said, easy......
# October 20, 2003 5:26 PM

Elrey Velicaria said:

I created a Web Service (asmx) that goes around the application recycling and uses a timer to make it alive 24 x 7. No need for scheduler, no need for windows timer. It works fine. I used the service to start, stop it, look at status. BTW, the application is a notification app ( much like e-minder). :)
# October 20, 2003 9:43 PM

Brian Desmond said:

I think there is a ThreadTimer or TimerThread class that you can put a thread on a timer too.
# October 21, 2003 10:04 PM

zhichao hong said:

windows task scheduler is much simpler than Unix cron. For example, there is no apparent way to schedule an hourly task! The pycron pointed by Janus1 is a good one.
# May 15, 2004 5:17 PM