Search code examples
pythonpython-schedule

I want run a job on buissness days only in the python schedule module


does anyone know how to do this in the python schedule module? there is little to no documention on what I want to do.

my code is:

schedule.every().day.at("21:05:00").do(turn_off)
schedule.every().Monday.at("06:00").do(turn_on)
schedule.every().Tuesday.at("06:00").do(turn_on)
schedule.every().Wednesday.at("06:00").do(turn_on)
schedule.every().Thursday.at("06:00").do(turn_on)
schedule.every().Friday.at("06:00").do(turn_on)
schedule.every().Monday.at("07:40").do(turn_off)
schedule.every().Tuesday.at("07:40").do(turn_off)
schedule.every().Wednesday.at("07:40").do(turn_off)
schedule.every().Thursday.at("07:40").do(turn_off)
schedule.every().Friday.at("07:40").do(turn_off)
schedule.every().Monday.at("16:05").do(turn_on)
schedule.every().Tuesday.at("16:05").do(turn_on)
schedule.every().Wednesday.at("16:05").do(turn_on)
schedule.every().Thursday.at("16:05").do(turn_on)
schedule.every().Friday.at("16:05").do(turn_off)

Solution

  • You can give it a try and confirm if it works for you.

    Run schedule from Monday to Friday

    schedule.every().monday.to(friday).at("06:00").do(job)
    schedule.every().monday.to(friday).at("07:40").do(job)