123456789101112131415161718192021222324252627 |
- import time
- from apscheduler.schedulers.blocking import BlockingScheduler
- from datetime import datetime
- import os
- def job1():
- # os.chdir(r'C:/gitlab/news_seo1/content_farm/AI/')
- os.system('python3 click_choozmo.py')
- # os.system('python3 smallset.py')
- print(f'工作1啟動: 目前時間{datetime.now().strftime("%Y-%m-%d %H:%M:%S")}')
- scheduler = BlockingScheduler(timezone="Asia/Taipei")
- job1()
- # 每1分鐘執行job1函式
- scheduler.add_job(job1, 'interval', minutes=2)
- #scheduler.add_job(job2, 'interval', seconds=5)
- # 每1秒執行job3函式
- #scheduler.add_job(job3, 'interval', seconds=1)
- # 每週二到日的下午6點30分執行job4函式
- #scheduler.add_job(job4, 'cron', day_of_week='1-6', hour=18, minute=30)
- scheduler.start()
- print('Schedule started ...') # 這行不會被執行
|