在 .NET 3.5 中创建一个长时间运行的夜间任务以在 Windows Server 2008 上使用

发布于 2024-08-12 15:11:35 字数 218 浏览 7 评论 0原文

我有一个长时间运行、计算和磁盘密集型的任务,需要每晚在 Window Server 2008 上运行;我选择的框架是.NET 3.5 sp1。该任务也有可能因多种原因(即缺乏磁盘空间)而失败,我想确保错误得到处理和处理。报告合理。此外,此任务需要权限才能执行创建数据库连接和读/写文件系统等操作。有哪些选项可以完成这样的事情?

编辑:我的问题更多是关于是否使用 Windows 计划或其他机制来启动该过程。

I have a long running, compute and disk intensive task that needs to run nightly on Window Server 2008; my Framework of choice is .NET 3.5 sp1. There's a chance this task could fail too for any number of reasons (i.e. lack of disk space) and I'd like to make sure errors are handled & reported reasonably. Also, this task would require permission to do things like create a database connection and read/write to the file system. What options are available for getting things like this done?

Edit: My question is more about whether to use windows schedule or some other mechanism to kick off the process.

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

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

发布评论

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

评论(5

小红帽 2024-08-19 15:11:35

创建控制台应用程序。在 main() 方法中,放置一个 try-catch,并使用 SmtpClient 发送有关未处理异常的通知。编译它并添加一个条目以使用计划任务小程序运行它。

Create a Console Application. Inside the main() method, put a try-catch, and use SmtpClient to send notifications about unhandled exceptions. Compile it and add an entry to run it using the Scheduled Task applet.

数理化全能战士 2024-08-19 15:11:35

这听起来像是一个标准的控制台应用程序,需要在一组计划(Windows 计划任务)上运行,并且需要简单的日志记录/报告和通信功能,可能还需要一些用于 db crud 操作的 linq2sql。

坦率地说,在这一点上,听起来你的选择是敞开的。

This sounds like it's just a standard console application that needs to run on a set scheduled (Windows Scheduled Tasks) and needs simple logging/reporting and communication capabilities and probably some linq2sql for db crud operations.

Frankly, at this point, it sounds like your options are wide open.

残月升风 2024-08-19 15:11:35

两个词……异常处理

另一个词……日志记录

除了这里其他人提供的所有其他非常合理的建议之外,如果这是一个长时间运行的进程,需要无人值守运行,我会特别注意您如何处理异常以及如何记录/报告它们,以便您知道是否出现问题并有足够的信息来纠正问题。

Two words ... exception handling

One other word ... logging

In addition to all the other very sound advice offered by the others here, if this is to be a long running process to run unattended, I would pay extra attention to how you handle exceptions and how you log/report them so that you know if something went wrong and have enough information to correct the issue.

梦里南柯 2024-08-19 15:11:35

您还有更具体的问题吗?所有这一切都是完全可行的。
您可以捕获异常并将其记录在日志文件中,然后使用 SMTP 邮寄这些结果。
您还可以连接到数据库,这非常简单。您是否遇到任何一件事需要我们帮助?

您可以使用 Windows 调度程序将此应用程序设置为在特定时间或持续时间运行的作业等。

Do you have more specific questions? All of this is totally doable.
You can catch and log exceptions in a log file, and mail those results using SMTP.
You can also make connections to a database which is very simple. Is there one single thing that you are having problems with that we could help?

You can use the windows scheduler to set this app up as say a job to run at a specific time or duration, etc.

还不是爱你 2024-08-19 15:11:35

编码它......问题是什么?
创建一个能够处理所有事情的良好可靠的代码,你就会完成你的任务。
你可以用它创建一个服务,并要求Windows在失败时重新启动,或者只是用try / catch all将其包装在无限循环中,但要处理那些如果不修复则不值得继续的事情......

Code it.... What is the question ?
Create a good solid code that handles everything and you'll have your task.
you can make a service out of it, and ask windows to restart if fails, or just wrap it in an infinate loop with try / catch all but take care of things that if not fixed won't worth continue....

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