An extremely simple way to schedule programs with Python on Windows
While every operating system has their own rendition of a scheduler such as the famous CRON on Linux or Windows Task Scheduler, sometimes a simpler option that can be controlled via a script offers extra utility across machine and platform.
schedule
is a python package aiming to offer such an option. It provides a lightweight alternative to the status quo and makes it especially simple to run a python function on a schedule with human readable configuration. The project has multiple contributors, a passing test suite and many followers on Github adding to its prevalence and intrigue.
Options
Scheduling a function in schedule
simply requires using the examples below and providing a function as a job to run.
import schedule
import time
def job():
print("I'm working...")schedule.every(10).seconds.do(job)
schedule.every(10).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)
schedule.every(5).to(10).minutes.do(job)
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)
schedule.every().minute.at(":17").do(job)while True:
schedule.run_pending()
time.sleep(1)