1. 程式人生 > 其它 >windows 定時排程datax json任務

windows 定時排程datax json任務

比較忙,好久沒有寫東西了。今天沒啥事剛好有個小需求

需求:後端部分資料從大資料平臺抽取到數倉(以web分的8個模組幾十張表吧)

1.之前直接用txt寫的python datax.py XXX.json 發現效率賊特碼低,能跑個十幾二十分鐘,轉而用python直接寫個多執行緒,為了方便直接吧各個模組的json放在各個模組了,反正表比較少,也懶得用執行緒池了。

直接8個執行緒同時起飛。

程式碼如下(非原始碼)start.py

import os
import threading

credit = os.listdir(r'E:\datax\job\credit')
manage = os.listdir(r'
E:\datax\job\manage') zcgl = os.listdir(r'E:\datax\job\zcgl') huresources = os.listdir(r'E:\datax\job\huresources') retail = os.listdir(r'E:\datax\job\retail') industclient = os.listdir(r'E:\datax\job\industclient') institution = os.listdir(r'E:\datax\job\institution') investment = os.listdir(r'E:\datax\job\investment
') def credit1(): for i in credit: os.system(r"python E:\datax\bin\datax.py E:\datax\job\credit\\" + i) def manage1(): for i in manage: os.system(r"python E:\datax\bin\datax.py E:\datax\job\manage\\" + i) def zcgl1(): for i in zcgl: os.system(r"python E:\datax\bin\datax.py E:\datax\job\zcgl\\
" + i) def huresources1(): for i in huresources: os.system(r"python E:\datax\bin\datax.py E:\datax\job\huresources\\" + i) def retail1(): for i in retail: os.system(r"python E:\datax\bin\datax.py E:\datax\job\retail\\" + i) def industclient1(): for i in industclient: os.system(r"python E:\datax\bin\datax.py E:\datax\job\industclient\\" + i) def institution1(): for i in institution: os.system(r"python E:\datax\bin\datax.py E:\datax\job\institution\\" + i) def investment1(): for i in investment: os.system(r"python E:\datax\bin\datax.py E:\datax\job\investment\\" + i) def main(): t1 = threading.Thread(target=credit1) t2 = threading.Thread(target=manage1) t3 = threading.Thread(target=zcgl1) t4 = threading.Thread(target=huresources1) t5 = threading.Thread(target=retail1) t6 = threading.Thread(target=industclient1) t7 = threading.Thread(target=institution1) t8 = threading.Thread(target=investment1) # t1.start() t2.start() t3.start() t4.start() t5.start() t6.start() t7.start() t8.start() # if __name__ == '__main__': main()

之後寫了個bat

內容python start.py

2.windows 中有個任務執行計劃

over