Python Forum

Full Version: multiple schedules?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
# OP is a python noob trying to streamline some performance monitoring work so he doesn't have to hire more people to do that
# Python 3.7

i'm having issues trying to execute the same .py files multiple times a day with "schedule" function. so i copied and pasted this file multiple times and changed their names. so now i have main_1.py, main_2.py and main_3.py with the same exact code. then i created a new file main_run.py with the following code:

import schedule
import time

def m_1():
    import main_1
def m_2():
    import main_2
def m_3():
    import main_3

schedule.every().day.at("10:00").do(m_1)
while True:
    schedule.run_pending()
    time.sleep(59)

schedule.every().day.at("13:00").do(m_2)
while True:
    schedule.run_pending()
    time.sleep(59)

schedule.every().day.at("16:00").do(m_3)
while True:
    schedule.run_pending()
    time.sleep(59)
but it still only runs main_1.py at 10:00 but not others. no error message either. would love to know what's the proper way to do scheduling in python. Cry
I am sorry, but why don't you want to use a scheduler built into your OS like 'cron'?