Scheduled Tasks for Web Applications

2019-06-28 05:04发布

What are the different approaches for creating scheduled tasks for web applications, with or without a separate web/desktop application?

11条回答
祖国的老花朵
2楼-- · 2019-06-28 05:35

I think Stack Overflow itself is using an ApplicationCache expiration to run background code at intervals.

查看更多
你好瞎i
3楼-- · 2019-06-28 05:36

I think Windows' built-in Task Scheduler is the suggested tool for this job. That requires an outside application.

查看更多
Viruses.
4楼-- · 2019-06-28 05:40

If we're talking Microsoft platform, then I'd always develop a separate Windows Service to handle such batch tasks.

You can always reference the same assemblies that are being used by your web application to avoid any nasty code duplication.

查看更多
男人必须洒脱
5楼-- · 2019-06-28 05:40

A very simple method that we've used where I work is this:

  1. Set up a webservice/web method that executes the task. This webservice can be secured with username/pass if desired.
  2. Create a console app that calls this web service. If desired, you can have the console app send parameters and/or get back some sort of metrics for output to the console or external logging.
  3. Schedule this executable in the task scheduler of choice.

It's not pretty, but it is simple and reliable. Since the console app is essentially just a heartbeat to tell the app to go do its work, it does not need to share any libraries with the application. Another plus of this methodology is that it's fairly trivial to kick off manually when needed.

查看更多
家丑人穷心不美
6楼-- · 2019-06-28 05:40

Java and Spring -- Use quartz. Very nice and reliable -- http://static.springframework.org/spring/docs/1.2.x/reference/scheduling.html

查看更多
Lonely孤独者°
7楼-- · 2019-06-28 05:53

Use URL fetchers like wget or curl to make HTTP GET requests.

Secure your URLs with authentication so that no one can execute the tasks without knowing the user/password.

You can also tell cron to run php scripts directly, for example. And you can set the permissions on the PHP file to prevent other people accessing them or better yet, don't have these utility scripts in a web accessible directory...

查看更多
登录 后发表回答