someName
someName

Reputation: 1273

How to schedule a batch job to run at a specific point in time?

In a C#/asp.net application I search for a way to schedule jobs to be executed once, at a specific point in time. Eg. at February 4th 2016 at 02:00. That is:

  1. Are there any frameworks out there that can do this (scheduling jobs for execution at a specific point in time)? I know Tivoli Workload Scheduler from IBM but that seems rather aged and expensive.

  2. It would be nice if the framework came with a web dashboard allowing job administrators to administer (schedule and overview) jobs I some calendar like view.

Upvotes: 0

Views: 5274

Answers (3)

László Koller
László Koller

Reputation: 1159

If you are running on a Windows-based server, then you could use the Revalee open source project to solve this issue. Revalee, which runs as a Windows Service, stores all scheduled tasks in a persistent data store (specifically, the Extensible Storage Engine (ESE) [aka. JET Blue]), so that you will not lose state even if your entire server needs to be rebooted. When your task is due, Revalee calls your application back in order to trigger whatever task you needed to run.

For example, from within your C# ASP.NET application you would register a Revalee callback like so (after installing & configuring the Revalee.Client package):

private void ScheduleSendMessage()
{
   // The callback time will be 4 Feb 2016 2:00 UTC (example assumes UTC)
   DateTimeOffset callbackTime = new DateTimeOffset(2016, 2, 4, 2, 0, 0, 0, TimeSpan.Zero);
   // The callback url is set (your send message code will reside there)
   Uri callbackUrl = new Uri("http://mywebapp.com/SendMessage.aspx");
   // Register the callback request with the Revalee service
   RevaleeRegistrar.ScheduleCallback(callbackTime, callbackUrl);
}

Upvotes: 0

LDJ
LDJ

Reputation: 7304

Hangfire does exactly what you want by passing a DateTime value into the schedule method:

BackgroundJob.Schedule(yourMethodCall, new DateTime(2015, 03, 07, 12, 00, 00))

Comes with a nice web front end too :)

Upvotes: 4

Wim Reymen
Wim Reymen

Reputation: 200

If you want to schedule the job in c#, check out http://www.quartz-scheduler.net/

Upvotes: 0

Related Questions