다른 명령
파이썬 스케줄러 모듈 - 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