如何在 Windows Server 上模拟 cron 作业? [英] How to emulate cron jobs on a Windows Server?

查看:27
本文介绍了如何在 Windows Server 上模拟 cron 作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 机器上运行 .NET,我希望每晚午夜运行一个函数.当然,由于 HTTP 无状态和 Windows 没有cron 作业"类型函数(我知道),我要么必须每晚在午夜亲自访问我的网站,要么等待用户访问该网站以依赖它的更新.

I'm running .NET on a windows box and I would like to have a function run every night at midnight. Of course since HTTP stateless and Windows doesn't have a "cron job" type function (that I know of), I will either have to visit my site myself every night at midnight or just wait for a user to visit the site to rely on it being updated.

是否有替代方法可以让我创建在特定时间自动运行的东西?

Is there an alternative to this that I can create where something will automatically run at a certain time?

推荐答案

如果其他答案都不适合您,这里有一个选项:

If none of the other answers work for you, here's an option:

那里有一堆服务器监控服务,它们会定期(如果您愿意的话,每分钟)对您的站点进行一次 http 调用.您可以在其中一些免费获得 5 分钟的间隔时间.

There are a bunch of server monitoring services out there that will make an http call to your site at regular intervals (every minute if you like). You can get 5 minute intervals for free on some of them.

创建一个受密码保护的页面,该页面执行您的功能(如果今天尚未完成)并将该服务指向它.

Create a password protected page, that performs your function (if it hasn't been done yet today) and point that service at it.

至少这样你就不必再写任何东西了,而且你可以放心,因为它不依赖于你的家用机器.

At least this way you won't have to write anything additional, and you can rest easy knowing it doesn't rely on your home machine.

这篇关于如何在 Windows Server 上模拟 cron 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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