0

I am using Python to schedule a Looker API job to run every second Friday of each month. Looker suggested using the crontabguru to check the code. I tried this code but it didn't work: 00 16 8-14 * */5 despite the crontab showed At 16:00 on every day-of-month from 8 through 14 if it's on every 5th day-of-week https://crontab.guru/#00_16_8-14_*_*/5

I found this post but I couldn't replicate it for Python: How to schedule to run first Sunday of every month

Thanks guys

mpaus
  • 9
  • 2
  • Do you understand the logic in the post to which you've linked? It runs the cronjob *every* sunday, but includes some shell logic to check if the day of the month is < 7. You could do something similar, although the logic for "is this the second friday" is going to be tricker than "is this the first friday". – larsks Sep 20 '22 at 02:11
  • `crontab` doesn't have method for `"second friday"` and you will have to check it on your own in code – furas Sep 20 '22 at 03:51
  • Thanks for looking into this. I understand the logic in the post. But I am new to Python so I don't know (1) how to add this shell logic to a Python code like create_simple_schedule(123, 234, "testing", "csv", "abc@abc.com", "email", "Hi Looker User!", "00 16 8-14 * */5") - the last part is the crontab code. (2) how to change the logic to run it every second Friday – mpaus Sep 20 '22 at 03:51
  • run it every friday and inside script check if it second friday - day 8-14. OR run in days `8-14` and inside script check if it is friday. – furas Sep 20 '22 at 03:53
  • What happens when you use `00 16 8-14 * */5`? Does the Looker API not accept the schedule, or does the job run at the wrong times? – Pēteris Caune Sep 20 '22 at 05:45

0 Answers0