Search code examples
azurecron

NCRONTAB Expression in Azure WebJobs


I am looking for the following schedule using CRON Expressions

Runs every hour from 9 AM to 5 PM => "schedule": "0 0 9-17 * * *" => working

Runs every 2 hours from 9 AM to 5 PM => "schedule": "0 0/120 9-17 * * *" => not working

The format per hour is (0-23) hence it is not recognizing.

How I can achieve the following then? Runs every 2 hours from 9 AM to 5 PM

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

https://github.com/atifaziz/NCrontab


Solution

  • Alternative solutions.

    0 0 9,11,13,15,17 * * *
    

    Because the requirements are not complicated, you can list the time to be executed one by one.

    Each field has a range, so your second one is not feasible.