Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple schedules?
#1
# 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
Reply
#2
I am sorry, but why don't you want to use a scheduler built into your OS like 'cron'?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020