How reliable is windows task scheduler for schedul

2019-04-29 19:00发布

I have a bit of code that needs to sit on a windows server 2003 machine and run every minute.

What is the recommended way of handling this? Is it ok to design it as a console service and just have the task scheduler hit it ever minute? (is that even possible?) Should I just suck it up and write it as a windows service?

8条回答
姐就是有狂的资本
2楼-- · 2019-04-29 19:31

I would say that it depends on what it was doing, but in general I am always in favor of having the fewest layers. If you write it as a console service and use the task scheduler then you have two places to maintain going forward.

If you write it as a windows service then you only have one fewer places to check in case something goes wrong.

查看更多
手持菜刀,她持情操
3楼-- · 2019-04-29 19:33

I agree, it is kind of a waste of effort to create even a console executable and schedule it to be run every minute. I would suggest exploring something like Quartz.Net. That way you can create a simple job and schedule it to run every minute.

查看更多
We Are One
4楼-- · 2019-04-29 19:34

The only other point to consider, is that if you're job involves some kind of database interaction, consider looking into the integration/scheduling services provided by your database.

For example, creating an SSIS package for your SQL Server related service may seem a bit like overkill, but it can be integrated nicely with the environment and will have its own logging/error checking mechanisms already in place.

查看更多
Viruses.
5楼-- · 2019-04-29 19:40

if you need to have it run every minute, I would build it as a windows service. I wouldn't use the scheduler for anything less than a daily task.

查看更多
唯我独甜
6楼-- · 2019-04-29 19:46

While searching for scheduled service help, i came across to a very good article by Jon Galloway.

There are various diadvantages if a windows service is used for scheduled task. I agreed with it. I would suggest to use Task Scheduled, simple in implementation. Please refer to detailed information of implementing the task scheduler. Hope this info helps in finalizing the implementation approach.

查看更多
Evening l夕情丶
7楼-- · 2019-04-29 19:53

Windows Scheduled Tasks has been fairly reliable for our purposes and we favor them in almost all cases over Windows Services due to their ease of installing and advanced recovery features. The always on nature of a windows service could end up being a problem if a part of the code that was written ends ups getting locked up or looped in a piece of code that it shouldn't be in. We generally write our code in a fashion similar to this

Init();
Run();
CleanUp();

Then as part of the Scheduled Task we put a time limit on how long the process can run and have it kill the process if it runs for longer. If we do have a piece of code that is having trouble Scheduled Tasks will kill it and the process will start up in the next minute.

查看更多
登录 后发表回答