Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scheduled task or windows service

My team is having a debate which is better: a windows service or scheduled tasks. We have a server dedicated to running jobs and currently they are all scheduled tasks. Some jobs take files, rename them and place them in other directories on the network. Other jobs extract data from SQL, modify it, and ship it elsewhere. Other jobs ftp files out. There is a lot of variety, but all in all, they are fairly straightforward.

I am partial to having each of these run as a windows service instead of a scheduled task because it is so much easier to monitor a windows service than a scheduled task. Some are diametrically opposed. In the end, none of us have that much experience to provide actual factual comparisons between the two methods. I am looking for some feedback on what other have experienced.

like image 468
user177213 Avatar asked Sep 22 '09 14:09

user177213


People also ask

What is the difference between Windows service and Task Scheduler?

A Windows service in meant to run an application 24/7 and it has many recovery options. Task Scheduler is meant to run an application periodically and not 24/7; therefore there isn't any recovery option.

Is a Scheduled Task a service?

Services are for running "constant" operations all the time. Scheduled Tasks are for running single units of work at scheduled intervals (what you want).

When should you use Windows services?

Take advantage of Windows services to build applications that you want to run in the background or execute automatically at predefined intervals of time. A Windows service is a long-running application that can be started automatically when your system is started.

Can you schedule a Windows service?

The Task Scheduler service allows you to perform automated tasks on a chosen computer. With this service, you can schedule any program to run at a convenient time for you or when a specific event occurs.


3 Answers

If it runs constantly - windows service.

If it needs to be run at various intervals - scheduled task.

like image 163
wefwfwefwe Avatar answered Oct 22 '22 23:10

wefwfwefwe


Scheduled Task -

  1. When activity to be carried out on some fixed/predefined schedule.
  2. It take less memory and resources of OS.
  3. Not required installation.
  4. It can have UI (eg. Send reminder mail to defaulters)

Windows Service -
  1. When a continue monitoring is required.
  2. It makes OS busy by consuming more.
  3. Require install/uninstallation while changing version.
  4. No UI at all (eg. Process a mail as soon as it arrives)

Use them wisely

like image 23
Sumit Kapadia Avatar answered Oct 22 '22 21:10

Sumit Kapadia


Sceduling jobs with the build in functionality is a perfectly valid use. You would have to recreate the full functionality in order to create a good service, and unless you want to react to speciffic events, I see no reason to move a nightly job into a service.

Its different when you want to process a file after it was posted in a folder, thats something I would create a service for, thats using the filesystem watcher to monitor a folder.

I think its reinventing the wheel

like image 4
Heiko Hatzfeld Avatar answered Oct 22 '22 23:10

Heiko Hatzfeld