I am trying to configure a recurring task in my MVC application starting at 00:00 every day. I know this can be achieved by RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Daily);
.
Now my question is does hangfire cron work on basis of UTC time or the local time at server. If it works on local time, is there a way to run that on UTC time? I have to do this because this will be a day end process and all the scheduled tasks are scheduled based on the Universal time in my database.
To execute a job in UTC
time zone, you can provide TimeZoneInfo
as TimeZoneInfo.Utc
while defining your jobs.
RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Daily, TimeZoneInfo.Utc);
To execute a job in local time zone you can use TimeZoneInfo.Local
.