標籤:cer style 指定 str exp 電腦 建議 detail 參考
系統平台:windows系統,其他動作系統請參考其他資料。
Kettle內建的定時任務調度不太穩定,而且必須開啟Kettle,可以通過windows的工作排程器調用Kettle的Kitchen.bat來實現定時作業。
網上找了一些Kitchen.bat的參數,也是一知半解,沒有深入研究。
kitchen.bat 後面可以是-也可以是/然後再加options
Options:
/rep : Repository name
/user : Repository username
/pass : Repository password
/job : The name of the job to launch
/dir : The directory (dont forget the leading /)
/file : The filename (Job XML) to launch
/level : The logging level (Basic, Detailed, Debug, Rowlevel, Error, Nothing)
/logfile : The logging file to write to
/listdir : List the directories in the repository
/listjobs : List the jobs in the specified directory
/listrep : List the available repositories
/norep : Do not log into the repository
/version : show the version, revision and build date
/param : Set a named parameter =. For example -param:FOO=bar
/listparam : List information concerning the defined parameters in the specified job.
/export : Exports all linked resources of the specified job. The argument is the name of a ZIP
file.
而options 後面可以是=也可以是:也可以是空格
kitchen.bat /file d:\ 或者 -file=D:\ 或者/file:D:\等等都可以。。。
下面正式開始建立調用方案
1:建立開機檔案,用於被windows工作排程器調用
建立文字檔,重新命名為 "每日9點執行.bat",檔案右鍵編輯,以文字檔方式開啟,然後複製下面內容進去,儲存。
1 D:2 cd D:\pdi-ce-6.0.0.0-353\data-integration3 kitchen.bat -rep:XXX -dir:/ -job:"XXX" -user:XXX -pass:XXX -level:Basic -log:D:\kettlebat\log\每日9點執行%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.txt
註:第一行D:到第三行的kitchen.bat為開啟Kettle的Kitchen.bat,該檔案一般在Kettle的根目錄,請根據實際儲存路徑修改。
-rep:後的XXX修改為資產庫名稱,-job:後的XXX修改為要執行的作業名稱,-user:和-pass:後的XXX為資產庫的帳號密碼,
-level為記錄層級,共有Basic, Detailed, Debug, Rowlevel, Error, Nothing六種層級,此處使用Basic,其它層級自行測試,
-log後為日誌儲存路徑,路徑中的%date和%time是在建立日誌的時候給日誌名添加上時間。
2:新增工作計劃
右鍵電腦或者我的電腦,選擇管理,選擇工作排程器。或者通過其他方式開啟,總之開啟工作排程器就對了。
點擊右側建立基本任務,輸入任務名稱,點擊下一步設定觸發器,點擊下一步設定具體的觸發條件,這裡可以設定成各種各樣的定時任務。
點擊下一步設定作業為啟動程式,然後選擇上面建立的 每日9點執行.bat,然後點擊完成即可。
上面為建立基本任務,設定比較簡單,功能比較弱,建議建立任務時直接點擊建立任務,指定更加可靠的任務,比如設定不管使用者是否登入都要運行、設定任務失敗後的重啟次數、設定任務的逾時時間等。
主要代碼來自於前輩翟大神,敬禮。
使用windows內建任務計劃管理程式定時 調用Kettle作業