[python] 특정 날짜와 시간에 대한 작업 예약하기
먼저, schedule
라이브러리를 설치합니다.
pip install schedule
이제 특정 작업을 예약하기 위해 다음과 같은 예제 코드를 사용할 수 있습니다.
import schedule
import time
def job():
print("작업 실행됨")
schedule.every().day.at("10:30").do(job)
while True:
schedule.run_pending()
time.sleep(1)
위의 예제에서는 매일 10:30에 job
함수가 실행되도록 예약되었습니다. 프로그램은 schedule
에 의해 주기적으로 체크되며, 예약된 작업이 있는지 확인합니다.
참고 자료:
schedule
라이브러리 문서: https://schedule.readthedocs.io/- Python 패키지 인덱스(PyPI) -
schedule
: https://pypi.org/project/schedule/