Web应用程序如何在共享主机上实现调度任务?

发布于 2024-12-18 07:55:54 字数 356 浏览 3 评论 0原文

据我所知,quartz.net调度程序是在global.asax中启动的。也就是说,除非有人访问该网站,否则 quartz.net 调度程序不会工作。这不是一种安全的方法,因为调度程序线程可以通过重新启动服务器或终止 IIS 池中的进程来终止,并且调度程序线程将保持未启动状态,直到有人再次访问该网站。

我们可以使用Windows调度程序来解决这个问题。但我们使用的是共享主机,我们无法在主机上编写服务或sql server作业或安排windows任务。

如果我们确定我们的网站每天都会被访问,那么这不是问题。 如果没有,我们如何确保网络调度程序始终工作,即使几天没有人访问我们的网站,即使服务器重新启动?

As far as I know, the quartz.net scheduler is started in the global.asax. That's to say, quartz.net scheduler does not work unless someone visits the website. This is not a safe way because the scheduler thread can be killed by rebooting server or the process in the IIS pool being terminated, and the scheduler thread will remain unstarted until someone visits the website again.

We could use windows scheduler to solve this problem. But we are using a shared host and we cannot write a service or a sql server job or schedule a windows task on the host.

If we are sure that our site be visited every day, this is not a problem.
If not, how can we ensure that the web scheduler work all the time even if no one visit our site for days and even if the server is rebooted?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦与时光遇 2024-12-25 07:55:54

您应该将quartz.net 安装为Windows 服务,并通过远程处理从您的Web 应用程序访问它。这将保证调度程序始终运行。将调度程序设置为 Windows 服务的说明如下:
Quartz.Net 入门第 1 部分

You should install quartz.net as a windows service and access it from your web app via remoting. This will guarantee that the scheduler is always running. Instructions for setting up the scheduler as a windows service are here:
Getting Started with Quartz.Net Part 1

乖乖 2024-12-25 07:55:54

最简单的方法是让服务器上的计划任务触发您的作业(通过请求页面)。如果您没有可以执行此操作的服务器,您可以使用 pingdom 之类的东西以 n 间隔访问一个页面。

如果您确实有服务器来执行此操作,您也可以编写一个服务 - 但对于一些琐碎的事情,我只会使用计划任务。

The easiest way is to get have a Scheduled Task on the server trigger your job (by requesting the page). If you don't have a server that can do this you can use something like pingdom to hit a page at n intervals.

If you do have a server to do this you can also write a service - but for something trivial I'd just use a scheduled task.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文