1

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?

Lahari
  • 461
  • 1
  • 3
  • 16
  • Your code looks fine, check the timezone of the server you are running this application in. – Manoj Jun 20 '23 at 12:39

1 Answers1

1

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
S Anand
  • 11,364
  • 2
  • 28
  • 23