Azure Functions – Time Trigger (CRON) Cheat Sheet

This is a cheat sheet for CRON expressions used in the time triggers for Azure functions. They define how often a trigger/the Azure function should be executed (daily, hourly, every 3 months, …).

The basic format of the CRON expressions in Azure is:
{second} {minute} {hour} {day} {month} {day of the week}
e.g. 0 * * * * * (=every minute)

The following values are allowed for the different placeholders:

ValueAllowed ValuesDescription
{second}0-59; *{second} when the trigger will be fired
{minute}0-59; *{minute} when the trigger will be fired
{hour}0-23; *{hour} when the trigger will be fired
{day}1-31; *{day} when the trigger will be fired
{month}1-12; *{month} when the trigger will be fired
{day of the week}0-6; SUN-SAT; *{day of the week} when the trigger will be fired

e.g. 3 5 * * * * defines a trigger that runs every time when the clock is at second 3 and minute 5 (e.g. at 09:05:03, 10:05:03, 11:05:03, …).

The trigger executes at UTC timezone. So for Vienna (UTC+1), a trigger at 18:00 (UTC) executes at 19:00 Vienna time (UTC+1).

Examples

ExpressionDescriptionruns at
0 * * * * *every minute09:00:00; 09:01:00; 09:02:00; … 10:00:00
0 */5 * * * *every 5 minutes09:00:00; 09:05:00
0 0 * * * *every hour (hourly)09:00:00; 10:00:00; 11:00:00
0 0 */6 * * *every 6 hours06:00:00; 12:00:00; 18:00:00; 00:00:00
0 0 8-18 * * *every hour between 8-1808:00:00; 09:00:00; … 18:00:00; 08:00:00
0 0 0 * * *every day (daily)Mar 1, 2017 00:00:00; Mar 2, 2017 00:00:00
0 0 10 * * *every day at 10:00:00Mar 1, 2017 10:00:00; Mar 2, 2017 10:00:00
0 0 * * * 1-5every hour on workdaysMar 3 (FRI), 2017 22:00:00; Mar 3 (FRI), 2017 23:00:00; Mar 6 (MON), 2017 00:00:00
0 0 0 * * 0every sunday (weekly)Mar 5 (SUN), 2017 00:00:00; Mar 12 (SUN), 2017 00:00:00
0 0 9 * * MONevery monday at 09:00:00Mar 6 (MON), 2017 09:00:00; Mar 13 (MON), 2017 09:00:00
0 0 0 1 * *every 1st of month (monthly)Mar 1, 2017 00:00:00; Apr 1, 2017 00:00:00; May 1, 2017 00:00:00
0 0 0 1 1 *every 1st of january (yearly)Jan 1, 2017 00:00:00; Jan 1, 2018 00:00:00; Jan 1, 2019 00:00:00
0 0 * * * SUNevery hour on sundayMar 5 (SUN), 2017 23:00:00; Mar 12 (SUN), 2017 00:00:00; Mar 12 (SUN), 2017 01:00:00
0 0 0 * * SAT,SUNevery saturday and sundayMar 3 (SUN), 2017 00:00:00; Mar 11 (SAT) 00:00:00; Mar 12 (SUN), 2017 00:00:00
0 0 0 * * 6,0every saturday and sundayMar 3 (SUN), 2017 00:00:00; Mar 11 (SAT) 00:00:00; Mar 12 (SUN), 2017 00:00:00
0 0 0 1-7 * SUNevery first sunday of the month at 00:00:00Mar 5 (SUN), 2017 00:00:00; Apr 2 (SUN), 2017 00:00:00
11 5 23 * * *daily at 23:05:11Mar 1, 2017 23:05:11; Mar 2, 2017 23:05:11
30 5 /6 * * *every 6 hours at 5 minutes and 30 seconds06:05:30; 12:05:30; 18:05:30; 00:05:30
*/15 * * * * *every 15 seconds09:00:15; 09:00:30; … 09:03:30; 09:03:45; 09:04:00

(the most common expressions are bold)

Attention: the following CRON expression is valid and you can use it, but there is an issue with it:
0 0 */5 * * *

It means every 5 hours, so the job executes at: 00:00:00, 05:00:00, 10:00:00, 15:00:00. 20:00:00, 00:00:00 …
This is not exactly every 5 hours and its the reason why CRON expressions should be dividable by the maximum value. The following values are good if you want a regular frequency:

  • for minutes and seconds: /2, /3, /4, /5, /6, /10, /12, /15, /20 and /30 (60 is divisible by these numbers)
  • for hours: /2, /3, /4, /6, /8 and /12
  • for months: /2, /3, /4 and /6
  • for days: nothing, because there are leap years and months with 28, 29, 30 or 31 days.

All other values can lead to “wrong” executions at the end of a “cycle”. e.g. every 7 hours executes at 00:00, 07:00, 14:00, 21:00, 00:00 (only 3 hours – not 7)

Additional information

Azure Functions timer trigger: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer
Wikipedia CRON expression: https://en.wikipedia.org/wiki/Cron#CRON_expression
Working with Azure functions (part 1 – Powershell): https://arminreiter.com/2016/11/working-azure-functions-part-1-powershell/
Working with Azure functions (part 2 – C#): https://arminreiter.com/2016/11/working-with-azure-functions-part-2-c/
CRON Expression Descriptor: http://cronexpressiondescriptor.azurewebsites.net/

Categories:

47 Responses

    • Good question – I added it to the samples above. I would construct it as:
      0 0 0 1-7 * SUN
      At 0 seconds, 0 minutes, 0 hours on 1st, 2nd, …. or 7th day of the month on sundays. So at 00:00:00 on sunday with “day of month” between 1 and 7.

  1. Nice and thanks.

    But how would you trigger in on the 15 if that is a working day else the next working day ?

    • Hi ludwig,

      I see two possibilities to solve it: The first is to check it in your logic. So the CRON expression is:
      0 0 0 15-17 * *
      So it runs every 15th, 16th and 17th.

      In your logic you check at first if:
      15th AND workday or
      NOT 15th AND monday

      Another possibility is to use 2 CRON expressions that cover the logic above:
      0 0 0 15 * 1-5 (every 15th on monday-friday)
      0 0 0 16,17 * 1 (every 16th or 17th on monday)

      • what if you want to trigger on the previous work day, not the next?
        Trying to trigger at the first of every month, unless its not a working day – then i want to trigger on the previous working day.
        for example the first of september 2018 is a saturday, so i want the trigger to happen on the 31 of august instead

  2. hi, good post, been looking for something like this for a while.

    but are you sure about allowed values for hour being 1-23? i would expect it to be 0-23.

  3. Thanks loads! It’s been frustrating going through a lot of resources which all document slightly different formats.

  4. Thanks for the wonderful post!

    How can I set the CRON expression for every fortnight? or something like 14,28 of every month?

  5. Adding “WEBSITE_TIME_ZONE” in the config can adjust the times its fired relate to the timezone set.

    eg: WEBSITE_TIME_ZONE=”GMT Standard Time”

    Comes in handy for daylight savings time changes

    • Did you figure out how to specify the last day of every month? I tried “L” (based on some other posts but did not work

      0 45 16 L * * (e.g. 4:45pm on the last days)?

  6. Hi My App works fine for seconds(*/15 * * * * *) but not for minutes(0 */15 * * * *).

    here my logs:
    2018-10-04T12:42:13 Welcome, you are now connected to log-streaming service.
    2018-10-04T12:42:20.622 [Information] Executing ‘Functions.ImageFunction’ (Reason=’This function was programmatically called via the host APIs.’, Id=ab4d55f-0fbe-3u1s-ab31-ba8b21443df6)
    2018-10-04T12:42:20.632 [Error] Executed ”Functions.ImageFunction” (Failed,

  7. Hello, How can you run the job in a different time and different days?

    Ex –
    Monday at 3pm
    Tuesday at 7pm
    Friday at 12pm

  8. Is there a “*” missing in the example “30 5 /6 * * *”? I would write it as “30 5 */6 * * *”.

  9. Hello,
    This does not work:
    “0 */10 7-20 * * 1-6” –> Every 10 minutes between 7 and 20 hours from Monday to Saturday

  10. Hi!

    I’m trying to accomplish something that I don’t think can even be done (and probably not with TimeTrigger, but it’s worth asking here):

    Do you think there’s a way to make a funciton that runs only once, automatically, once an App Service is started and then never again (until it’s stopped and re-started?).

    • I know that if we were working with CRON-CRON (not this slightly different version used by Azure) I could just use “@reboot”, right? I think that’s what I’m looking for: an alternative to @reboot in Azure TimerTrigger

  11. I have a one web job … i want to schedule the job in below timings what will the cron expression used ? please let me

    02:30 AM EST  07:30:00 AM UTC
    09:00 PM EST  02:00:00 AM UTC
    10:00 AM EST  03:00:00 PM UTC
    11:00 AM EST  04:00:00 PM UTC

  12. Nice read! Thank you for the article. How can I configure a job to run every other Monday at 9:30 am.

  13. Can we create a terraform code for the above timed trigger azure function? I could not find this anywhere. Thanks

  14. Hi, I know its an old article but please consider updating it as this is one of the first search result when searching for “azure function cron”.

    Last I checked and tested, for an Azure Function, the “Allowed Values” for “{day of the week}” in this article are misleading (“0-6; MON-SUN; *”). The correct day names for 0-6 would be SUN-SAT since 0 = SUN and not MON. As described, it would only ON MON and SUN (an no other days of the week)

  15. I have a question. I need to run every Saturday at 7pm and also on the 21st of the all months at 7pm, how would it look?

  16. Excellent, helpful cheat sheet. The CRON expression formatting used in Azure might not be obvious for everybody (it wasn’t for me), so this taught me how to accomplish what I wanted. Thanks for posting.

  17. Hi everyone,
    i have an azure function timer trigger and i would like to use it in ADF by changing the cron expression to never let the azure function trigger by itset (with the cron). Basically it’s an Azure function timer trigger, but the trigger comes from ADF and not the CRON.
    Thank you,

  18. I need to schedule job every day at 3am and 8pm
    I did it like 0 0 3,20 * * *
    Job ran but invoices not getting created.
    What went wrong?

  19. You wrote wrong every hour (hourly) cron expression. It must be “0 * * * *” instead of “0 0 * * * *”

  20. Hi

    Is it possible to write an azure cron trigger that runs the program once every 4 weeks? Not the fourth week of the month but every 4th week.

  21. hi , I need cron expression for every 2nd friday at 1 a.m for every month.

    I have created this 0 0 13 2-7 * FRI

    is this correct?

Leave a Reply

Your email address will not be published. Required fields are marked *

About
about armin

Armin Reiter
Azure, Blockchain & IT-Security
Vienna, Austria

Reiter ITS Logo

Cryptix Logo

Legal information