16

I scheduled a webjob to run daily at 2 am using cron expression (0 0 2 * * *) following tutorial from Create a scheduled WebJob using a CRON expression and my server is created in "north central US" region, so i hope it should run in US central timezone but seems it running at different time than what i specified.

Chandra_S
  • 319
  • 4
  • 14

2 Answers2

21

Based on the comments mentioned here, WebJobs run into the timezone configured for the WebApp where your WebJob is hosted. From this post:

enter image description here

Assuming you have not configured anything for the timezone, your cron job should use UTC which is the default timezone in Azure.

From Changing the server time zone on Azure Web Apps, you can specify the time zone you want your application to run in by making an application setting called WEBSITE_TIME_ZONE and set it to a proper value. From this blog post:

If your app is hosted as a Web App on the Azure App Service (formerly known as Azure Websites), until recently you were completely out of luck. However there is now an easy and supported way to change the time zone for your w3wp process (and any processes it spawns):

All you need to do is add an Application Setting (via the portal or the management APIs) called WEBSITE_TIME_ZONE and set that to the name of the time zone as defined in the Windows Registry under HKLM\Software\Microsoft\Windows Nt\CurrentVersion\Time Zones\ (for example, “AUS Eastern Standard Time”).

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • 1
    I see it's running in UTC(GMT) timezone. – Chandra_S Jun 16 '16 at 10:57
  • 3
    Nice, didn't know about the reg key. I added that to the [wiki](https://github.com/projectkudu/kudu/wiki/Configurable-settings#set-the-time-zone). – David Ebbo Jun 16 '16 at 16:55
  • Thanks. Microsoft needs to stop hiding important documentation information into blog posts... (I was looking the answer to "Which TimeZone do WebJobs run on", I'm already using WEBSITE_TIME_ZONE and I wanted to make sure it would apply there too) – Thibault D. Dec 01 '16 at 15:04
  • 1
    Use with caution if you set it to a timezone with daylight saving time. If you use a daily pattern the run after the offset change will start on the wrong time. – Markus Mar 26 '18 at 14:18
  • How can I configure it so the DST is auto? – Csaba Toth Aug 27 '18 at 06:19
  • Valid values here: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc749073(v=ws.10) – Ben Robinson Apr 24 '20 at 13:10
  • 1
    I set my timezone to `GMT Standard Time`. The jobs are now running on UK time, which is technically incorrect as we are on BST (daylight savings). It's the result I wanted, but confusing! – Ben Robinson Apr 27 '20 at 10:54
0

The default time zone is GMT as per the MS documentation

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=csharp#ncrontab-time-zones