Scheduled Tasks for Web Applications

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

+4
source share
11 answers

If we are talking about the Microsoft platform, I would always develop a separate Windows service to handle such batch tasks.

You can always refer to the same assemblies used by your web application to avoid unpleasant duplication of code.

+3
source

Jeff discussed this on a qaru blog - http://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/

In principle, Jeff suggested using CacheItemRemovedCallback as a timer to invoke certain tasks.

I personally believe that automated tasks should be handled as a service, a scheduled Windows task, or a task on SQL Server.

On Linux, check cron.

+4
source

I think that Qaru itself uses ApplicationCache expiration to run background code at intervals.

+2
source

If you are on a Linux host, you will almost certainly use cron .

+2
source

On linux, you can use cron jobs ( http://www.unixgeeks.org/security/newbie/unix/cron-1.html ) to schedule tasks.

Use URLs like wget or curl to make HTTP GET requests.

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

+1
source

I think that the built-in Windows task scheduler is the proposed tool for this work. This requires an external application.

+1
source

This may or may not be what you are looking for, but read this article: " Simulate a Windows Service Using ASP.NET to Run Scheduled Tasks ." I think StackOverflow can use this method, or at least talked about using it.

+1
source

The very simple method that we used when I work is:

  • Set up the webservice / web method that performs the task. If necessary, this web service can be protected with a username / password.
  • Create a console application that calls this web service. If you wish, you can send the console application parameters and / or return some indicators for output to the console or external logging.
  • Schedule this executable in the task scheduler of choice.

It is not very, but simple and reliable. Since the console application is just one instant, to tell the application to do its job, it does not need to exchange libraries with the application. Another plus of this methodology is that it is pretty trivial to start manually when necessary.

+1
source

Use URLs like wget or curl to make HTTP GET requests.

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

You can also tell cron to run php scripts directly, for example. And you can set permissions for the PHP file so that other people do not access them, or even better, do not have these utility scripts in a directory accessible on the Internet ...

+1
source

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

+1
source

I think there are simpler ways than using cron (Linux) or Task Scheduler (Windows). You can create this in your web application using: (a) a quartz scheduler,

or if you do not want to integrate another third-party library into your application: (b) create a thread at startup that uses the standard Java class 'java.util.Timer' to complete your tasks.

0
source

Source: https://habr.com/ru/post/1276416/


All Articles