nix
nix

Reputation: 2285

Scheduling task versus service

I have a local and a remote dbs. For some reason, I want to synchornize the local with the remote one, say, every 5 minutes. Should I use a service that does the synchronizing using timer or schedule a task on windows server?

Upvotes: 1

Views: 172

Answers (3)

sekerg
sekerg

Reputation: 11

If you are using MS SQL Server and local (source) server has at least the Standart Edition or higher then you should think about using replication(SQL Server Express cannot serve as a Publisher or Distributor). If local server has Express edition but the remote server is Standart Edition or higher than you should set up a PULL subscription on remote side to pull data from Express server.

If replication is not a case then I would offer using a service(running with SYSTEM account) using timer, because you need to specify which Windows account will be used to run task for the scheduled task. When password for the account changed your tasks will not execute and even worse, you will not get any information about it.

If your frequency were a long time (once a week or once a day) then using a service should be considered as wasting system resources, but I think it is acceptable for a period of 5 minutes.

Upvotes: 1

liuzhidong
liuzhidong

Reputation: 548

Are you using Windows for the OS ? if yes, I would write a script file to synchronize the database, and put the script to the Task Scheduler.

For ubuntu, Scheduled Task would be my choice...

Upvotes: 0

Troy Gizzi
Troy Gizzi

Reputation: 2520

I used to always make a Windows Service for timed tasks. But several years ago, I switched to the Task Scheduler approach, with no regrets.

Here are the advantages I found from using the Task Scheduler approach:

  1. Less code to write (mainly because you don't have the overhead of a Timer)

  2. Easier to debug (just hit F5 and run it, since it's a normal EXE)

  3. Easier to kick off ad-hoc execution (in case you want to check the outcome right away sometime, instead of waiting until the next timed execution)

P.S. For future reference, this type of question should really be asked over in Programmers Stack Exchange, since it's about a design choice, as opposed to a problem with existing code.

Upvotes: 3

Related Questions