python - How can do repeatable job every m minutes between start hour until end hours for n days? -
i import schedule package in python , need run task example n days starts @ 1:00 , ends @ 1:30 every 10 minutes (3 times per day) , need repeat pattern until n days finish. many thanks!
how schedule jobs: https://schedule.readthedocs.io/en/stable/
how clear scheduled job: https://schedule.readthedocs.io/en/stable/faq.html#clear-job-by-tag
import schedule n_days = 5 # run 5 days tasks_done = 0 # track number of times run tasks_per_day = 3 # no of times task runs def do_task(): global tasks_done, tasks_per_day, n_days tasks_done += 1 print("i'm working...") if tasks_done >= (tasks_per_day * n_days): # n days on schedule.clear('daily-tasks') times = ["01:00", "01:10", "01:20"] t in times: schedule.every().day.at(t).do(do_task).tag('daily-tasks', t)
Comments
Post a Comment