Reputation: 55
Hi I gotta work with hangfire cron but I can't understand setting cron time ("***** is everysecond i know")
Also I searched there are some websites about that, but when i set some date i copied and paste anohter site and site says wrong type.
Hangfire makes some easy way to set time like
Cron.Daily //work on every day 00.00
Cron.HourInterval
I gotta work a function every day 14.00,How can i make it like
Cron.Daily(14)
or somethning else. Thank you
I'm really unsure. one site can genareta cron and it give this
work every weekday at 14.00
0 0 14 ? * MON-FRI *
other does not accepts it , it accepts this
0 14 * * *
Which one works for hangfire
Upvotes: 0
Views: 1043
Reputation: 11364
If you are looking to run the job week days at 2PM,
"0 14 * * MON,TUE,WED,THU,FRI"
"0 14 * * MON-FRI"
"0 14 * * 1,2,3,4,5"
"0 14 * * 1-5"
and if you want to do the job daily,
"0 14 * * SUN–SAT"
Documentation on cron expressions used by Hangfire.
Cron
Hangfire does have its own internal representation for the Cron Expressions but dont give you as much control like weekdays.. but they are there.
You can create a recurring job with the following syntax using Cron class from Hangfire.Core
. This recurring job will run every day at 1400 hours.
RecurringJob.AddOrUpdate("name", () => Test(), Cron.Daily(14));
You can also use a variety of other Cron methods available, including, Weekly(), Monthly(), Yearly
etc. All of these methods' definitions can be found here
Upvotes: 1