Scheduled Jobs in .NET Core 2 Web app hosted in AWS

耗尽温柔 提交于 2019-12-09 23:56:57

问题


We are starting a new project in .NET Core 2, I will be needing some approach to run a scheduled job that will do some work. This app will be hosted in Linux server or AWS linux instance. I have done this with Azure WebJobs and .NET 4.6. How is this done with .Net Core and Linux


回答1:


I dont know who upvoted this question. I went out and used Hangfire Jobs. Pretty easy to work. not actually a scheduled job. But we can start it with a Run() and be on our way doing other things. No need to wait for it to end. If anyone need a detail. plz comment




回答2:


Depending on your use case maybe implementing the IHostedService interface (available since .NET Core 2.1, with copy-paste also useable with .NET Core 2.0) is sufficient. If you just want to do some periodic clean-up in the background, you could run it using a timer. See: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/hosted-services?view=aspnetcore-2.1

The advantage of implementing IHostedService is that you can react to the shutdown of the service.



来源:https://stackoverflow.com/questions/46321059/scheduled-jobs-in-net-core-2-web-app-hosted-in-aws

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