VOOZH about

URL: https://www.nuget.org/packages/Frank.CronJobs/

⇱ NuGet Gallery | Frank.CronJobs 3.0.0




👁 Image
Frank.CronJobs 3.0.0

dotnet add package Frank.CronJobs --version 3.0.0
 
 
NuGet\Install-Package Frank.CronJobs -Version 3.0.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Frank.CronJobs" Version="3.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Frank.CronJobs" Version="3.0.0" />
 
Directory.Packages.props
<PackageReference Include="Frank.CronJobs" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Frank.CronJobs --version 3.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Frank.CronJobs, 3.0.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Frank.CronJobs@3.0.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Frank.CronJobs&version=3.0.0
 
Install as a Cake Addin
#tool nuget:?package=Frank.CronJobs&version=3.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Frank.CronJobs

A simple library for running jobs on a schedule using cron expressions. Also the cron part is reusable and can be used standalone.

This library is designed to be used with the Microsoft.Extensions.DependencyInjection library, and it is designed to be as easy and simple to use as possible. It is also designed to be as flexible as possible.

It is built on the library, but with a different API and approach.


👁 NuGet
👁 NuGet

👁 GitHub contributors
👁 GitHub Release Date - Published_At
👁 GitHub last commit
👁 GitHub commit activity
👁 GitHub pull requests
👁 GitHub issues
👁 GitHub closed issues


Usage

This library is designed to be used with the Microsoft.Extensions.DependencyInjection library. It is designed to be used list this in your Program.cs file:

using Frank.CronJobs;

var services = new ServiceCollection();
services.AddCronJob<MyJob>("0 15 10 * * ?");

var serviceProvider = services.BuildServiceProvider();

await serviceProvider.StartAsync();

class MyJob : ICronJob
{
 public Task ExecuteAsync(CancellationToken cancellationToken)
 {
 Console.WriteLine("Hello, world!");
 return Task.CompletedTask;
 }
}

This will start the job at 10:15 AM every day. The MyJob class should implement the ICronJob interface, and the ExecuteAsync method should be implemented. This method will be called every time the cron expression is satisfied.

Advanced Usage

If you want to stop or modify the job, you can use the IScheuleMaintainer interface to stop, start, or modify any job at runtime like this:

var maintainer = serviceProvider.GetRequiredService<IScheduleMaintainer>();
maintainer.Stop<MyJob>();

This will stop the job from running. You can also start it again by calling Start<MyJob>(). You can also modify the schedule and timezones of the job by calling SetSchedule<MyJob>("0 15 10 * * ?") and SetTimeZone<MyJob> ("America/New_York") respectively.

The job runner is added as a hosted service, so it will run as long as the application is running.

The scenario for editing the schedule at runtime is meant to make it flexible for the user to change the schedule of the job without having to restart the application, or specify the schedule in a configuration file, and so anything that can have the opportunity to change the schedule at runtime. A service that react to IOptions changes, for example, can look like this:

public class MyService
{
 private readonly IOptionsMonitor<MyOptions> _optionsMonitor;
 private readonly IScheduleMaintainer _scheduleMaintainer;

 public MyService(IOptionsMonitor<MyOptions> optionsMonitor, IScheduleMaintainer scheduleMaintainer)
 {
 _optionsMonitor = optionsMonitor;
 _scheduleMaintainer = scheduleMaintainer;
 _optionsMonitor.OnChange(OnOptionsChange);
 }

 private void OnOptionsChange(MyOptions options)
 {
 _scheduleMaintainer.SetSchedule<MyJob>(options.CronExpression);
 // etc.
 }
}

Installation

Install the NuGet package directly from the package manager console:

PM> Install-Package Frank.CronJobs

License

Frank.CronJobs is licensed under the .

Contributing

Contributions are welcome, please submit a pull request after you create an issue if you have any ideas or find any bugs. Major changes should be discussed in an issue before submitting a pull request. Also, no new dependencies unless discussed and agreed upon in an issue first.

Credits

This library is based on CronQuery, which I am a contributor to. This is built on that code for the basic cron functionality, and some patterns and ideas are borrowed from that project. This is however a separate implementation, and the code is not shared between the two projects. CronQuery has a lot longer history and is better tested, so I recommend using that library if you need a more stable and tested library; I made this library because I wanted to register the jobs in the DI container and its schedule at the same time, which is not possible with CronQuery nor would I presume it would be a good idea to do so in that library.

Product Versions Compatible and additional computed target framework versions.
.NET net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Frank.CronJobs:

Package Downloads
Frank.WorkflowEngine

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 335 7/8/2025
2.1.13-preview 268 4/13/2025
2.1.12-preview 284 4/13/2025
2.1.0 349 12/6/2024
2.0.9-preview 238 7/11/2024
2.0.8-preview 225 6/24/2024
2.0.0 392 2/3/2024
1.1.7-preview 203 2/3/2024
1.1.6-preview 236 1/29/2024
1.1.5-preview 227 1/24/2024
1.1.0 287 1/21/2024
1.0.4-preview 215 1/21/2024
0.1.0 330 12/30/2023