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 :)

12 Comments

  • Windows cron = Scheduled Tasks

  • 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?



  • 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.







  • 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.

  • 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!

  • 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

    -Christopher

  • Windows Service and a timer. Runs GREAT.



    Wally

  • 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 :) )

  • 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......

  • 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). :)

  • I think there is a ThreadTimer or TimerThread class that you can put a thread on a timer too.

  • 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.

Comments have been disabled for this content.