使用Windows任务与Windows服务来调用应用程序 [英] Using Windows Task vs Windows Service to invoke application

查看:104
本文介绍了使用Windows任务与Windows服务来调用应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码需要定期运行以保持两个数据库同步。确切的间隔尚未确定,但取决于它运行所需的时间。  我的猜测是它会一天运行几次。


我无法决定如何运行应用程序。  我在与Windows任务计划程序启动的可执行文件和为此创建Window服务之间进行辩论。这两种方法都有利有弊,这使得b $ b很难决定最佳方法。


可能还需要偶尔按需运行此代码,但是我不认为这会经常这样做。  我想确定我们是否具备此功能,但我们是否需要使用它。


这是我能够找到的每种方法提供的优势列表。  在这种情况下,是否有人应该添加任何内容或智慧珍珠?


预定任务优势:  



  • 更容易维护其运行的计划
  • 无需创建计时器
  • 更容易运行ad-hoc
  • 如果由于没有连续运行而导致内存泄漏,则会减少问题




服务优势:



  • 如果服务停止或挂起MOM或类似产品,则很容易提醒管理员。
  • 更容易监控
  • 更好地处理异常,因为它会记录并清除它们并重新启动服务
  • 屏幕上不会弹出控制台应用。 



解决方案

你好,


服务一般应该是用于启动/停止与应用程序相关的应用程序或工作流程相关的事件。  通常,正在运行的作业应该作为服务或sql作业运行。  如果
决定将作业作为计划任务运行,强烈建议使用正确的Windows服务帐户。  在此上下文中,服务帐户将登录服务器并从任务计划程序执行作业。  如果您需要收到有关失败的
作业的警报,您可以在作业本身或从任务计划程序中设置SMTP通知(如果配置正确)。  


另一个考虑因素是将数据库同步作为作业从其中一个数据库服务器运行。   SQL Server有一个非常好的作业配置和监视工具,用于运行SSIS包和t-sql存储过程
,可用作同步作业的一部分。 


问候。


I have code that needs to run periodically to keep two databases in sync. The exact interval hasn't been determined, but it depends on how long it takes for it to run.  My guess is it will run several times a day.

I'm having trouble deciding on how I want to run the application though.  I'm debating between an executable that's kicked off with Windows Task Scheduler and creating a Window's service for this. Both of these approaches have pros and cons which make it difficult to decide on the best approach.

There will probably also be a need to run this code on demand occasionally, but I don't think this will be done frequently.  I want to be sure we have this capability though should we need to use it.

This is the list of advantages I've been able to find that each approach offers.  Does anyone have any that should be added or pearls of wisdom with this type of situation?

Scheduled task advantages: 

  • Easier to maintain the schedule it runs on
  • No need to create a timer
  • Easier to run ad-hoc
  • Less issues if there is a memory leak because it isn't running continuously


Service advantages:

  • Easy to alert admins if the service stops or hangs with MOM or similar product.
  • Much easier to monitor
  • Deals with exceptions better because it will log and clear them and restart the service
  • No console app pops up on the screen. 

解决方案

Hello,

Services should generally be used for starting/stopping events related to an application or workflow related to an application.   Generally running jobs should either be run as services or as sql jobs.  If you decide to run the job as a scheduled task, it is highly recommended to use a proper windows service account.  In this context, the service account will logon the server and execute the job from the task scheduler.  If you need be alerted for failed jobs, you can set up SMTP notifications either in the job itself or from the task scheduler if properly configured.  

Another consideration is to run the database sync as a job from one of the database servers.  SQL Server has a very good job configuration and monitoring tool for running SSIS packages and t-sql stored procedure that may be used as part of your sync job. 

Regards.


这篇关于使用Windows任务与Windows服务来调用应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆