Schedule Cron Jobs using HostedService in ASP.NET Core | HOW TO - Code Samples

preview_player
Показать описание

#coding #codingbootcamp #softwaredeveloper #CodeYourFuture

In this video, we will go over the use case of scheduling cron jobs using a customized HostedService in an ASP.NET Core Web API project. The output will show the runtime logging for the final application, which has three background tasks running at every 5 minutes, every 1 minute, and every day at 12:50 PM.

The job schedules are defined by Cron Expressions. For example, the cron expression */5 * * * * represents a schedule of every 5 minutes, the cron expression * * * * * defines a minute-by-minute schedule, and the cron expression 50 12 * * * means 12:50 PM daily.

In order to parse the cron expressions, we add a NuGet package Cronos to the Web API project. The Cronos package is a lightweight but full-fledged library for parsing cron expressions and calculating next occurrences with time zones and daylight saving time in mind. The Cronos is an open source project sponsored by HangfireIO.

Lots of Great How Tos and Code Samples! Make sure to like and subscribe!
Рекомендации по теме