Scheduling to cron expression like * * 31 Feb * isn't currently possible. If such cron expression is provided then CrontabSchedule.GetNextOccurrence() should return DateTime.MaxValue (or DateTime.MinValue) as next schedule??
The rational behind it is, we want a named job that can be triggered manually. But we want it to be flexible enough for our user to choose if it should recur automatically or never occur (trigger manually).
Isn't this more of an implementation detail on your side? Can't you just add the job as recurring and remove if needed, and add a one-time job as necessary? Why require an invalid cron expression to determine your logic? Unless you are using the Dashboard as your job control.
@RupertAvery
We are not using dashboard as job control, but we want a webhook as our job control. But instead of webhook knowing all the details require to configure our job, we want a pre-configured named job. So that all webhook needs to do is:
POST - https://url-to-webhook/job-name
If adding invalid corn seems wrong, another option is to allow null cron value. But as far as I've seen around web, standard approach/advice with cron seems to be adding 31, feb for such scenario.
Hope this answers your questions? Please feel free to suggest if you can think of better way to do what we want.
There are few things we want to avoid:
BTW, a better feature request in my opinion would be to allow injecting : GetNextOccurrence() logic from out side. With that approach we can provide some fixed date or use cron library that fits our need.
I'd like this feature as well.
Any special value for the cron string could work (for example null as proposed by @nrip-monotype or maybe something more explicit like "never"). The idea for me is indeed to use the dashboard as job control for some special jobs on a web service system that currently has no user interface at all ; this would be very convenient.
Another use case is for development builds that do not automatically run tasks (for example because the tasks access expensive resources or risk modifying important data), but you still want to be able to trigger them by hand for testing purposes. The tasks would be configured with a regular cron string on production environment, but set to "never" on development environments.
The feature is now implemented in the latest 1.7.0 betas, and recurring jobs that never occur will be shown at the top of the list in the dashboard.
The feature is now implemented in the latest 1.7.0 betas, and recurring jobs that never occur will be shown at the top of the list in the dashboard.
Would you please document how to use this feature please? I can't find it actually and I would like to schedule a cron that never occurs.
Thanks a lot
Regards
I guess the cron to use is Cron.Never.
Thanks
Cron.Never still doesn't appear to be supported in .NET Core version of the Hangfire library (which appears to still only be v 1.7.0-beta1 with nothing more current to install). Am I missing something?
CORRECTION: The Hangfire library doesn't appear to be updated in the Hangfire Pro Nuget package source: https://nuget.hangfire.io/nuget/hangfire-pro
Pulling from Nuget and crossing my fingers.
Most helpful comment
I guess the cron to use is Cron.Never.
Thanks