Search code examples
schedulergramex

How can I setup Gramex scheduler on first monday of month and first monday of a quarter?


I tried this piece of code but it sends for every Monday every month or quarter. How can I restrict it to only the first Monday?

schedule:
  email-alerts-monthly:
    function: mymodule.check_email_alerts()
    weekday: mon
    months: '*' 
    utc: true

email-alerts-quarterly:
    function: mymodule.check_email_alerts()
    weekday: mon
    months: 'jan, apr, jul, oct' 
    utc: true

Any suggestions?


Solution

  • For the first Monday, add dates: 1-7. That will skip all subsequent weeks in the month, and still run it only on the first Monday.

    schedule:
      email-alerts-monthly:
        function: mymodule.check_email_alerts()
        dates: 1-7
        weekday: mon
        months: '*' 
        utc: true
    
    email-alerts-quarterly:
        function: mymodule.check_email_alerts()
        dates: 1-7
        weekday: mon
        months: 'jan, apr, jul, oct' 
        utc: true