Hi Team,
Thanks for such great system!
I have created a recurring job and given interval in min like below
RecurringJob.AddOrUpdate(() => sendMail(), Cron.MinuteInterval(5000000), TimeZoneInfo.Local);
-
But this job getting executed every hr. Is it correct or something is wrong.
-
In Hangfire all tables dates are saved in UTC format I need in local format is there any option for that.
Kindly help.
Thanks in advance!
Thanks & Regards
Sunita
1 Like
Actually, I ran into the same problem and had to read more about cron expressions. Please check this SO post - https://stackoverflow.com/questions/745901/how-to-do-a-cron-job-every-72-minutes. I did not try this approach with Hangfire, though, but at least it explains why it behaves that way
P.S. approximately expected behavior probably can be achieved using following expression (however, I just got a thought and did not test it yet , however, cron expression descriptor says it should work as expected)
public static string GetCronExpression(this int intervalMinutes) {
var timeSpan = TimeSpan.FromMinutes(intervalMinutes);
return $"{timeSpan.Minutes} */{timeSpan.Hours} * * *";
}
Update: code above works only up to 1439 minutes (24h - 1 minute)