How to Recurring Batch Job

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 ?

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.

1 Like

can you give simple example in c# ?

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"));
}

I tried this solution but I don’t see the batch running.
RecurringJob.AddOrUpdate(“easyjob”, () => StartBatchJobs(), Cron.Minutely);
public void StartBatchJobs() {
for (int i = 0; i < 5; i++)
{
BackgroundJob.Enqueue(j => j.Perform(i,null));
}
}