开发者

Scheduled .NET code execution in hosted environment?

开发者 https://www.devze.com 2022-12-09 00:22 出处:网络
I\'ve got about 4开发者_运维技巧0 lines of .NET code in a console application that read and RSS feed and store information in a database. I need this code to execute every night for as long as the RSS

I've got about 4开发者_运维技巧0 lines of .NET code in a console application that read and RSS feed and store information in a database. I need this code to execute every night for as long as the RSS feed exists (indefinitely). Currently, I just launch the console app. from my home computer.

Because I can't trust myself to remember to do this every night, I somehow need to have this code hosted. I'd like to somehow have this app. or code (it could easily be put in an ASP.NET page codebehind and triggered to execute when the page loads) run automatically without me having to run the console app. manually.

Any ideas?

EDIT: I don't want to run this code from my computer; I can't guarantee my computer will not be hibernating or connected to the Internet every night.

EDIT: Right now I'm thinking spawn a background thread using BackgroundWorker in Application_Start of the global.asax, have it download the RSS feed once a day, and Thread.Sleep() the rest of the time.


Although controversial, Jeff Atwood blogged about how they accomplished this for SO using cache expiration. Check it out at https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/.

You could use a similar method and schedule the cache to expire at the time you want the process to kick off.


You could use the Windows built-in task scheduler to start the console application.


I would suggest just using the 'at' command instead of getting this small app hosted somewhere.

C:\>at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.


Email your webhost. Some managed hosts will set up a scheduled task for you.

They will likely have different policies regarding how to call a scheduled task (i.e. some may require it to be an aspx page and not an EXE)


Have you looked at Quartz Scheduler for .NET?

Quoth the tagline: Quartz.NET is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems.

0

精彩评论

暂无评论...
验证码 换一张
取 消