Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Hangfire to perform recurrent tasks at specific time #4425


User avatar
0
soonjoo created

Hello team,

I have set up hangfire, and I can access the dashboard, however, how do I set up a recurring job so that it executes everyday at 12 midnight?

I have read the documentation and created a class which inherit BackgroundJob

public class DailyDataAggregatorJob : BackgroundJob<DailyDataAggregatorJobArgs>, ITransientDependency
    {
        public DailyDataAggregatorJob()
        {
        }

        [UnitOfWork]
        public override void Execute(DailyDataAggregatorJobArgs args)
        {
            Logger.Info("Inside DailyDataAggregatorJob");
        }
    }

however, where should I put the code the start this recurring job and tell them to execute it daily? according to the hangfire documentation I am supposed to add this line of code somewhere

RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Daily);

I have checked the abp documentation on background jobs but it doesn't demonstrate this.

thanks!


3 Answer(s)