运行计划任务的最佳方式 [英] Best way to run scheduled tasks

查看:481
本文介绍了运行计划任务的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我们已经建立了一个控制台应用程序运行的计划任务为我们的ASP.NET网站。但我认为这种做法是有点容易出错,难以维持。你如何执行你的计划任务(在窗口/ IIS / ASP.NET环境)

Today we have built a console application for running the scheduled tasks for our ASP.NET website. But I think this approach is a bit error prone and difficult to maintain. How do you execute your scheduled task (in an windows/IIS/ASP.NET environment)

更新:

任务的例子:


  • 发送电子邮件,队列邮件数据库

  • 从数据库中删除过时的对象

  • 从谷歌AdWords的统计数据检索和数据库中填写的表格。

推荐答案

我所有的任务(其中需预定)的网站被保留在网站内,并从一个特殊的页面调用。然后我写了一个简单的Windows服务,每隔一段时间调用这个页面。一旦页面运行它返回一​​个值。如果我知道有需要做更多的工作,我再次运行该页面,马上,否则我在一小会儿运行它。这工作对我很好,并保留我的所有任务逻辑与Web code。编写简单的Windows服务之前,我使用的Windows调度调用页面每隔x分钟。

All of my tasks (which need to be scheduled) for a website are kept within the website and called from a special page. I then wrote a simple Windows service which calls this page every so often. Once the page runs it returns a value. If I know there is more work to be done, I run the page again, right away, otherwise I run it in a little while. This has worked really well for me and keeps all my task logic with the web code. Before writing the simple Windows service, I used Windows scheduler to call the page every x minutes.

要运行这个另一种方便的方法是使用像 Pingdom的监控服务。点自己的HTTP检查是运行在服务code中的页面。具有然后可以用来触发Pingdom的发送警报消息时东西是不正确的页面返回的结果。

Another convenient way to run this is to use a monitoring service like Pingdom. Point their http check to the page which runs your service code. Have the page return results which then can be used to trigger Pingdom to send alert messages when something isn't right.

这篇关于运行计划任务的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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