Search code examples
pythondatetimepause

in python, how to pause until certain time only without date in pause library


I have python script and I want it to run at 10AM. I tried using with pause and datetime library like the code below

import pause
import datetime
pause.until(datetime.datetime(2021,1,6,10,00))

that means the script will pause until 6 January 2021 10.00 AM. What I want is, how to pause only certain time only the hour and the minute and seconds without putting the date there? is it possible?


Solution

  • Check out this library. I think it will suit your needs: https://pypi.org/project/schedule/

    You can code things like:

    import schedule
    import time
    
    def job():
        print("I'm working...")
    
    schedule.every().day.at("10:30").do(job)
    
    while True:
        schedule.run_pending()
        time.sleep(1)