https://velog.io/@jw3418/python%EC%9C%BC%EB%A1%9C-daemon-scheduler-%EA%B5%AC%ED%98%84
python으로 daemon scheduler 구현
데이터 자동 추가를 위해 linux crontab을 이용하려 했는데, 실행하고자 하는 crawling.py 파일에 외부 라이브러리가 많아서 그런지 (crontab 파일에 따로 library path를 추가해야 할듯?) crontab이 매달 실행
velog.io
참고 블로그
def job_function():
subprocess.run(args=[sys.executable, "./main.py"])
sched = BackgroundScheduler(timezone='Asia/Seoul')
# interval형식 5초마다 실행
job = sched.add_job(job_function, 'interval', seconds=5)
sched.start()
while True:
print("running")
time.sleep(1)
def print_hi(name):
print(f'Hi, {name}') # 중단점을 전환하려면 Ctrl+F8을(를) 누릅니다.
# 스크립트를 실행하려면 여백의 녹색 버튼을 누릅니다.
if __name__ == '__main__':
print_hi('Hello')
running
running
running
running
running
Hi Hello
https://apscheduler.readthedocs.io/en/3.x/modules/triggers/cron.html
apscheduler.triggers.cron — APScheduler 3.10.4.post1 documentation
Introduction This is the most powerful of the built-in triggers in APScheduler. You can specify a variety of different expressions on each field, and when determining the next execution time, it finds the earliest possible time that satisfies the condition
apscheduler.readthedocs.io
'파이썬' 카테고리의 다른 글
장고, 모델에서 db_table 외부 변경해보기 (0) | 2024.05.03 |
---|---|
pandas dataframe 이미지 테이블 export시 style로 멀티 인덱스 보이지 않게 하기 (0) | 2024.01.04 |
pyqt pyside scrollArea QScrollArea 맨 위로 스크롤 하기 (0) | 2023.12.04 |
파이썬 pyqt QComboBox style (0) | 2023.11.22 |
파이썬 pyqt pyside qcheckbox 테두리 style (1) | 2023.11.21 |