다른 명령
새 문서: == 파이썬 스케줄러 모듈 - APSchedule == https://apscheduler.readthedocs.io/en/latest/ Advanced Python Scheduler 파이썬의 스케줄러 모듈입니다. cron 또는 특정 주기로 해당 기능을 실행 하고자 할 경우 사용 === 설치 === # pip install apscheduler === 사용예시 === # scheduler.py <source lang=python> #!/usr/bin/env python #-*- coding: utf-8 -*- from datetime import datetime import time import os from apscheduler.schedulers.backgrou... |
잔글 개발노트 양식 일괄 적용 |
||
| 1번째 줄: | 1번째 줄: | ||
{{개발노트 | |||
|요약=Advanced Python Scheduler | |||
|핵심= | |||
|분야=Python | |||
|작성일=2024-10-04 | |||
}} | |||
== 파이썬 스케줄러 모듈 - APSchedule == | == 파이썬 스케줄러 모듈 - APSchedule == | ||
2026년 11월 12일 (목) 12:45 기준 최신판
DEVCAFE NOTE
PythonAdvanced Python Scheduler
KEY POINTS · 핵심 정리
파이썬 스케줄러 모듈 - APSchedule
https://apscheduler.readthedocs.io/en/latest/
Advanced Python Scheduler 파이썬의 스케줄러 모듈입니다. cron 또는 특정 주기로 해당 기능을 실행 하고자 할 경우 사용
설치
- pip install apscheduler
사용예시
- scheduler.py
#!/usr/bin/env python
#-*- coding: utf-8 -*-
from datetime import datetime
import time
import os
from apscheduler.schedulers.background import BackgroundScheduler
def tick():
print('Tick! The time is: %s' % datetime.now())
if __name__ == '__main__':
scheduler = BackgroundScheduler()
scheduler.add_job(tick, 'interval', seconds=3)
scheduler.start()
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
try:
# This is here to simulate application activity (which keeps the main thread alive).
while True:
time.sleep(2)
except (KeyboardInterrupt, SystemExit):
# Not strictly necessary if daemonic mode is enabled but should be done if possible
scheduler.shutdown()
- 실행
# chmod 700 scheduler.py # ./scheduler.py