使用Windows Service作为调度服务
我从客户那里收到这个问题,每天或每两周运行一些数据库脚本,具体取决于时间段的类型。 他们定义了“繁忙”时期和“安静”时期。 他们的应用程序使用共享托管,并且无法将 SQL Server 作业添加到数据库中。
我想要做的是创建一个 Windows 服务,它可以使用配置文件进行配置,包含不同的周期及其间隔。 该服务正在检查当前时间和日期与配置文件中的计划周期,一旦间隔匹配,就会执行 sql server 存储过程
我的问题:是否有更好的方法在没有 sql server 的情况下进行这种调度,或者您知道吗是否已经存在更通用(免费)的现有解决方案?
[编辑] 我无法使用Windows任务计划程序,因为他们的安静期是在冬天,而他们的繁忙期是在夏天。 使用任务计划程序,我必须每年手动修改计划任务两次。 这就是我和我的客户现在想要的。 [/编辑]
谢谢
I have this question from a client, to run some database scripts on a daily or biweekly basis, depending on the type of period. They have defined a 'busy' period and a 'quiet' period. They are using shared hosting for their applications and they can't add SQL Server jobs to their database.
What I want to do is create a windows service, which is configurable using a config file, containing the different periods and their intervals.
This service is checking the current time and date versus the scheduled periods in the configuration file and will execute a sql server stored procedure once the interval matches
My question: Is there a better way to do this kind of scheduling without sql server or do you know if an existing, more generic (free) solution already exists?
[Edit]I can't use windows task scheduler since their quiet period is during winter and their busy period is during summer. With task scheduler I'd have to modify the scheduled tasks manually twice a year. That's now what I nor my client wants.
[/Edit]
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Windows 的“计划任务”功能在需要时启动某些控制台应用程序。
如果您想创建自己的调度解决方案,那么我建议您查看 Quartz.NET ,它提供了与 Windows 任务计划程序相同的灵活性。
You could use "Scheduled Tasks" feature of windows to start some console application whenever it is required.
If you want to create your own scheduling solution, then I'd recommend to have a look at Quartz.NET, which offers the same flexibility as the windows task scheduler.
为什么不使用任务计划程序,然后每次应用程序启动时,它都会检查自己的计划以确定是否需要执行某些操作。
因此,您可以使用任务计划程序每 15 分钟启动一次应用程序。 当您的应用程序启动时,它使用自己的配置文件来确定是否需要执行某些操作。
您还可以使用它来让您的应用程序停止任何当前正在运行的应用程序版本,以终止任何长时间运行的任务!
Why not use the task scheduler and then every time your application gets started, it checks it's own schedule to work out whether or not it needs to do something.
So you could use the task scheduler to start your application every 15 minutes. When your application starts up it uses it's own configuration file to work out whether or not it needs to do something.
You could also use this to get your application to stop any currently running versions of your application to kill any long running tasks!