Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Tips and Traps

  1. If you schedule a job J1J_1 using schedule in IPython shell, and then interrupt the following loop that checks and runs pending jobs,

    while True:
        schedule.run_pending()

    the scheduled job J1J_1 is still there unless you stop the current IPython shell. The effective consequence of this is that if you schedule another job J2J_2, and start to run it using the following loop,

    while True:
        schedule.run_pending()

    the job J1J_1 will also continue to run! This might not what you expect since when you intterup the loop that checks and runs pending jobs, you might thought that you killed scheduled jobs, which is not correct.

Installation

pip3 install schedule

Example

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)
schedule.every().minute.at(":17").do(job)

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

schedule.job.do

Specifies the job_func that should be called every time the job runs. Any additional arguments are passed on to job_func when the job runs.