我有一个 EXE,需要每分钟运行一次。 我应该将其作为计划的 EXE 还是 Windows 服务来执行?

发布于 2024-07-21 00:03:21 字数 239 浏览 1 评论 0原文

我知道这主要是一种意见,但我很感兴趣您是否有这样的意见以及您的理由是什么。

重复Windows任务调度程序用于调度代码重复运行的可靠性如何?

I know this is largely an opinion, but I'm interested if you have one and what your reasons are.

Duplicate: How reliable is windows task scheduler for scheduling code to run repeatedly?

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

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

发布评论

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

评论(4

街角卖回忆 2024-07-28 00:03:21

我有很多这样的程序,我将它们作为服务与调度程序一起运行。 优点是无需任何用户登录即可运行。 另外我可以远程停止/启动。

I have many programs like this and I run all of them as a service with a scheduler. The advantage is that it can run without any user being logged on. Plus I can stop/start remotely.

漆黑的白昼 2024-07-28 00:03:21

我有一个类似的场景:

它是一个旧版 EXE,需要使用显式用户凭据每分钟运行一次,只需要在特定应用程序运行时运行(用户登录后),并且需要“昨天”完成。

因此,只需使用内置机制来使用计划任务运行就足够简单了。 不需要编写新代码,除非确实需要,否则它不会运行。

不过,我通常更愿意使用 Service 方法。

I had one similar scenario:

It was a legacy EXE, needed to run once a minute with explicit user credentials, only needed to run while a specific application was running (after the user logged in), and needed to be done "yesterday."

Hence, it was easy enough to just use the built-in mechanism to run using a scheduled task. No new code needed to be written and it would not run unless it really needed to.

I would typically rather use the Service approach, though.

撩发小公举 2024-07-28 00:03:21

与作为计划服务运行相比,将其作为服务运行时使用的 CPU 更少(这可能并不重要)。 但是,我会选择服务。

You will use less CPU running it as a service than as a scheduled service (not that it will matter likely). But, I would go with service.

最初的梦 2024-07-28 00:03:21

如果它可以有效地由多个用户独立运行,那么它可能最好由任务计划程序控制。 如果您没有源代码,那么编写一个包装器来执行任务调度程序的操作就没有多大意义。 我唯一一次计划任务失败的情况是在不稳定的网络上运行时(如果要在笔记本电脑上运行,请确保取消选中“仅使用交流电源”选项)。

但是,如果您可以重新编译它,并且它看起来像一项服务(可靠,需要在失败时恢复,将得到广泛部署等),您可能希望将其重新设计为一个服务。 除了提高效率之外,您还可以报告状态、明智地响应启动/停止请求以及添加智能定时。

If it can be usefully run standalone by multiple users, it's probably best controlled by the task scheduler. If you don't have the source code, there's not much point writing a wrapper that does what the task scheduler does anyway. The only times I've only had scheduled tasks fail is when running off a flaky network (make sure you untick the "only on AC power" option if it will run on a laptop).

However, if you can recompile it, and it look like a service (dependable, needs recovery on failure, will get widely deployed, etc.), you might want to rework it as one. In addition to being more efficient, you could then report status, respond sensibly to start/stop requests, and add intelligent timing.

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