I am using the Cronos library to handle my cron jobs on .NET Core.
However I have encountered this issue where the common Cron Expressions are not being parsed in at all. It keeps giving me a CronFormatException.
I have looked through the Github page and used their formats but I still get the same Exceptions.
This is my code:
services.AddCronJob<Worker1>(x =>
{
x.TimeZoneInfo = TimeZoneInfo.Local;
x.CronExpression = "* * * * * *";
});
I want to run it every second but I get the CronFormatException issue.
This is the library: https://github.com/HangfireIO/Cronos
Does this library use a different cron format?
You did not specify what you are doing in the AddCronJob
method, but I guess you are doing a CronExpression.Parse("* * * * * *")
method call somewhere, and this will throw the exception. To fix it you should change it to CronExpression.Parse("* * * * * *", CronFormat.IncludeSeconds)
like it says on the github page what you linked: https://github.com/HangfireIO/Cronos#adding-seconds-to-an-expression