码迷,mamicode.com
首页 > Windows程序 > 详细

使用windows自带任务计划管理程序定时 调用Kettle作业

时间:2017-04-22 12:50:00      阅读:1860      评论:0      收藏:0      [点我收藏+]

标签: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-integration
3 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作业

标签:cer   style   指定   str   exp   电脑   建议   detail   参考   

原文地址:http://www.cnblogs.com/jusha/p/6746918.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!