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
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
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
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.