-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·38 lines (30 loc) · 1.1 KB
/
run.py
File metadata and controls
executable file
·38 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import time
import asyncio
import schedule
from scripts.daily import daily_task
async def job(n):
await daily_task(n)
def run_job(n):
try:
asyncio.run(job(n))
print(f"크롤링 시간: {time.strftime('%Y-%m-%d %H:%M:%S')}")
except Exception as e:
print(f"작업 중 오류 발생: {e}")
print(f"오류 발생 시간: {time.strftime('%Y-%m-%d %H:%M:%S')}")
print(f"프로그램 시작 시간: {time.strftime('%Y-%m-%d %H:%M:%S')}")
run_job(n = 5)
print(f"프로그램 종료 시간: {time.strftime('%Y-%m-%d %H:%M:%S')}")
# # 매일 아침 6시에 실행하도록 스케줄 설정
# schedule.every().day.at("06:00").do(run_job, n = 2)
# def main():
# try:
# while True:
# schedule.run_pending()
# time.sleep(1)
# except KeyboardInterrupt:
# print(f"\nKeyboard Interrupt로 인한 종료 시간: {time.strftime('%Y-%m-%d %H:%M:%S')}")
# except Exception as e:
# print(f"예외로 인한 종료: {e}")
# print(f"예외 발생 시간: {time.strftime('%Y-%m-%d %H:%M:%S')}")
# if __name__ == "__main__":
# main()