Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent to cron jobs in ASP.NET?

In PHP we have cron jobs, where the hosting server automatically picks up and executes a task as per the schedule given.

What would be a good alternative to use for CRON jobs in ASP.NET? I'd like to use a Web service, but that will not work in a shared hosting environment. Any help would be appreciated, and please advise a way to do this specifically in a shared hosting environment.

like image 717
Farooq Ahmed Khan Avatar asked Nov 22 '11 12:11

Farooq Ahmed Khan


People also ask

What is the alternative for cron job?

Anacron - Anacron is a periodic command scheduler just like cron. The only difference is that it does not need your computer to be always running. fcron - Fcron is the best of both cron and anacron. It doesn't require your computer to be running 24×7, and it can work with tasks on an hourly or minute basis.

What is cron job in asp net?

A cron job is a Linux command used for scheduling tasks to be executed sometime in the future. This is normally used to schedule a job that is executed periodically – for example, to send out a notice every morning. Some scripts, such as Drupal and WHMCS may require you to set up cron jobs to perform certain functions.

Is cron job and background job same?

For that purpose, as a system administrator, you can define background jobs (for example, database clean-ups) which are executed without any need for user interaction. These jobs are typically referred to as cron jobs.

What is difference between scheduler and cron job?

Cron allows you to create your own chains manually. Scheduler allows you to place resource control (CPU limits, undo tablespace limits, etc) against your job. It allows you to define classes with priorities and assign jobs to those classes.


2 Answers

Try Quartz.NET. It's a decent .NET scheduler which supports CRON expressions, CRON triggers and various other means and methods to schedule tasks to be performed at certain times / intervals.

It even includes a basic Quartz.NET server (Windows Application) that might fit your needs.

Edit:

If you can't run applications or windows services within your shared hosting then perhaps something like "Easy Background Tasks in ASP.NET" will do you? It simulates a Windows Service using HttpRuntime.Cache and removes the need for any external dependancies.

like image 161
Johannes Kommer Avatar answered Sep 19 '22 15:09

Johannes Kommer


This is absolutely a hack, but you can simulate a cron service using ASP.NET callbacks. Here is an example of how to do it.

like image 34
Cotega Avatar answered Sep 18 '22 15:09

Cotega