How to run cron job every day in asp. Net core application?

对着背影说爱祢 提交于 2020-12-05 12:33:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!