나의 개발일지

[Python] schedule 모듈 본문

백준

[Python] schedule 모듈

YoonJuHan 2023. 12. 18. 12:40
schedule 모듈을 사용하면 원하는 시간, 주기마다 코드를 실행할 수 있다.
설치 : pip install schedule

 

import schedule
import time
 

def start():
    print("start function")
 
# 10분마다 호출  
schedule.every(10).minutes.do(start)
 
# 1시간마다 호출  
schedule.every().hour.do(start)
 
# 매일 00시에 호출  
schedule.every().day.at("00:00").do(start)
 
# 5~10분 마다 수행
schedule.every(5).to(10).minutes.do(start)
 
# 매주 월요일 수행
schedule.every().monday.do(start)
 
# 매주 월요일 18:00에 수행
schedule.every().monday.at("18:00").do(start)
 
while True:
    schedule.run_pending()
    time.sleep(1)
Comments