There are many explanations that it is executed at a specified time or at a specified interval, I couldn't find a case to specify the time zone and execution frequency at the same time, so I implemented it by the following method. I would appreciate it if you could teach me if there is a better way.
import datetime
import time
import schedule
#Start job def startJob():
schedule.every(10).minutes.do(runJob)
print('startJob:' + str(datetime.datetime.now()))
def runJob():
print('runJob:' + str(datetime.datetime.now()))
def endJob():
print('endJob:' + str(datetime.datetime.now()))
for jobV in schedule.jobs:
if 'runJob()' in str(jobV):
schedule.cancel_job(jobV)
break
schedule.every().day.at("12:00").do(startJob)
schedule.every().day.at("13:00").do(endJob)
while True:
schedule.run_pending()
time.sleep(1)
Recommended Posts