Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scheduled task or windows service

I have to create an app that will read in some info from a db, process the data, write changes back to the db, and then send an email with these changes to some users or groups. I will be writing this in c#, and this process must be run once a week at a particular time. This will be running on a Windows 2008 Server.

In the past, I would always go the route of creating a windows service with a timer and setting the time/day for it to be run in the app.config file so that it can be changed and only have to be restarted to catch the update.

Recently, though, I have seen blog posts and such that recommend writing a console application and then using a scheduled task to execute it.

I have read many posts talking to this very issue, but have not seen a definitive answer about which process is better.

What do any of you think?

Thanks for any thoughts.

like image 482
czuroski Avatar asked May 11 '10 14:05

czuroski


3 Answers

If it is a one per week application, why waste the resources for it to be running in the background for the rest of the week.

A console application seems much more appropriate.

The typical rule of thumb that I use is something along these lines. First I ask a few questions.

  1. Frequency of Execution
  2. Frequency of changes to #1
  3. Triggering Mechanism

Basically from here if the frequency of execution is daily or less frequent I'll almost always lean towards a scheduled task. Then looking at the frequency for changes, if there is a high demand for schedule changes, I'll also try to lean towards scheduled tasks, to allow no-coding changes for schedule changes. lastly if there is ever a thought of a trigger other than time, then I'll lean towards windows services to help "future proof" an application. Say for example the requirement changes to be run every time a user drops a file in X folder.

like image 133
Mitchel Sellers Avatar answered Sep 24 '22 12:09

Mitchel Sellers


The basic rule I follow is: if you need to be running continuously because events of interest can happen at any time, use a service (or daemon in UNIX).

If you just want to periodically do something, use a scheduled task (or cron).

The clincher here is your phrase "must be run once a week at a particular time" - go for a scheduled task.

like image 32
paxdiablo Avatar answered Sep 25 '22 12:09

paxdiablo


If you have only one application and you need it to run once a week may be scheduler will be good as there is no need to have separate service and process running on the system which will be idle most of the time.

like image 36
Incognito Avatar answered Sep 24 '22 12:09

Incognito