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)
-
0
How: Duplicate of #4084@f49f2625-f54c-4486-a701-ce50d5e16ed5
<cite>alirizaadiyahsi: </cite>
Abp.HangFire.AspNetCore is already referenced in AspNetZero. You can use it directly. After you apply this step: https://aspnetzero.com/Documents/Development-Guide-Core#background-jobs-and-hangfire then you can also use Hangfire API. Just write Hangfire code.
Where: Duplicate of #2645@b7f111ed-945f-4b50-9722-d62c0b9a22be
<cite>Hozkar: </cite> I'm trying to define my Recurring Jobs in the Postinitialize Method of my Web Module
Also see the second topic for solutions to potential issues.
-
0
Hi @aaron,
Thank you for your reply, I had managed to get my code working after looking at the example code in those topics!
-
0
That's great :)