问题
I have a web application written in asp. Net mvc core 2.2. O need to run a schedule job every day at 3:00 Am. What is the best way to do it?
I tried hangfire it stops after some time. We need to set IIS server always running. I googled and found hosted service in. Net core. Can anyone tell me what is the best approch to run a job daily in web application in dot net core?
回答1:
I've not personally tried it for .NET Core honestly, but have you tried Quartz Scheduler? https://www.quartz-scheduler.net/ By this article, it seems you can use it with .NET Core as well
回答2:
You can use Hangfire.
You can create recurring function with CRON pattern.
RecurringJob.AddOrUpdate(() => Console.Write("Powerful!"), "0 12 * */2");
Documentation available here.
来源:https://stackoverflow.com/questions/61372133/how-to-run-cron-job-every-day-in-asp-net-core-application