In coding, you often need to run tasks on a schedule or at fixed intervals, such as:

  • Every 10 minutes
  • Everyday at 10:30 AM
  • Every Wednesday at 1:15 PM

While it’s possible to implement the functionality youself, reinventing the wheel is unnecssary.
Let me introduce the Python schedule module.

Install:

pip install schedule

Code Sample:

import schedule
import time

def job():
print("I'm working...")

schedule.every(10).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)

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

It is natural and straightforward.
I love it.

Contents
  1. 1. Install:
  2. 2. Code Sample: