mercredi 30 janvier 2019

Using Python with Schedule library with an IF statement

Hoping for some help with the scheduling a python script. I understand the syntax, but since I've added the IF statement logic, I can't get the script to run for two days in a row. The next morning it will either only run the daily job OR skips it entirely and only runs the fifteen-minute job. I need the if logic so the jobs runs on the weekdays only. Does anyone have any clever workarounds?

Thanks for the help. I included a simplified version of my code below:

import schedule
import time

def daily_job(text):
    print(text)

def fifteen_min_job():
    print('15 minute job...')

if True: # For example only run on weekdays
    schedule.every().day.at("09:32").do(daily_job, text='daily job...')
    schedule.every(15).minutes.do(fifteen_min_job)

while True:
    schedule.run_pending()
    time.sleep(1)

Aucun commentaire:

Enregistrer un commentaire