How to Recurring Batch Job

recurring
Tags: #<Tag:0x00007f8ba04179d0>

#1

let say i have

RecurringJob.AddOrUpdate(
    () => batchId ,
    Cron.Daily);
    var batchId = BatchJob.StartNew(x =>
    {
        x.Enqueue(() => Console.WriteLine("Job 1"));
        x.Enqueue(() => Console.WriteLine("Job 2"));
    });

How should my code will be to perform batchjob using recurringjob ?


#2

I’m not 100% sure what you’re asking, but I don’t think you can Schedule a Recurring Batch.

If you can’t, you could schedule a recurring Background Job and inside that Background Job kick off your Batch Jobs.


#3

can you give simple example in c# ?


#5

Probably something like:

public static void buttonTest_Click()
{
    RecurringJob.AddOrUpdate("StartBatchJobs", () => StartBatchJobs(), Cron.Daily);
}

public static void StartBatchJobs()
{
    BackgroundJob.Enqueue(() => Console.WriteLine("Job 1"));
    BackgroundJob.Enqueue(() => Console.WriteLine("Job 2"));
}