{"id":25522210,"url":"https://github.com/dotnet-labs/serviceworkercronjob","last_synced_at":"2025-10-03T21:50:28.836Z","repository":{"id":39795972,"uuid":"278251783","full_name":"dotnet-labs/ServiceWorkerCronJob","owner":"dotnet-labs","description":"Schedule Cron Jobs using HostedService in ASP.NET Core","archived":false,"fork":false,"pushed_at":"2024-09-28T12:50:56.000Z","size":107,"stargazers_count":264,"open_issues_count":1,"forks_count":71,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-26T01:08:47.733Z","etag":null,"topics":["aspnetcore","cron","cronjob","cronjob-scheduler","dotnet","dotnetcore","hostedservices"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotnet-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"changhuixu","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-07-09T03:20:04.000Z","updated_at":"2025-05-08T14:14:33.000Z","dependencies_parsed_at":"2025-02-28T06:17:24.684Z","dependency_job_id":"21054dde-ce17-4aab-9c65-22d097b0ea45","html_url":"https://github.com/dotnet-labs/ServiceWorkerCronJob","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dotnet-labs/ServiceWorkerCronJob","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FServiceWorkerCronJob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FServiceWorkerCronJob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FServiceWorkerCronJob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FServiceWorkerCronJob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnet-labs","download_url":"https://codeload.github.com/dotnet-labs/ServiceWorkerCronJob/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FServiceWorkerCronJob/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278234029,"owners_count":25953075,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnetcore","cron","cronjob","cronjob-scheduler","dotnet","dotnetcore","hostedservices"],"created_at":"2025-02-19T18:18:44.602Z","updated_at":"2025-10-03T21:50:28.815Z","avatar_url":"https://github.com/dotnet-labs.png","language":"C#","funding_links":["https://ko-fi.com/changhuixu","https://ko-fi.com/changhuixu'"],"categories":[],"sub_categories":[],"readme":"# Service Worker Cron Jobs Demo\n\n\u003ca href='https://ko-fi.com/changhuixu' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\nYou may want to ask, \"_What's the difference between a hosted service and a background thread?_\" The difference is that the hosted service will be started and stopped with the application. While, when starting a background thread, the thread cannot gracefully handle clean-up actions and will be killed when the application is stopped. The `HostedServiceExecutor` will handle the starting and stopping of a hosted service, which allows for graceful cleanup when the application is stopped.\n\nStarts from version 2.1, .NET Core provides a native abstract base class `BackgroundService`, which includes common operations for background jobs such as `CancellationToken` and housekeeping works.\n\n## [Medium Article: Schedule Cron Jobs using HostedService in ASP.NET Core](https://codeburst.io/schedule-cron-jobs-using-hostedservice-in-asp-net-core-e17c47ba06)\n\nIn this blog post, we will go over the use case of scheduling cron jobs using a customized `HostedService` in an ASP.NET Core Web API project. The following screen recording shows 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.\n\n![Cron Jobs](./cron-jobs.gif)\n\n## License\n\nFeel free to use the code in this repository as it is under MIT license.\n\n\u003ca href='https://ko-fi.com/changhuixu' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-labs%2Fserviceworkercronjob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnet-labs%2Fserviceworkercronjob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-labs%2Fserviceworkercronjob/lists"}