Datastage 调度相关 dsjob

DataStage有他自己的调度,不过个人总觉得修改起来不怎么方便。于是偏向于在Linux下用shell调度。最近项目需要,总结了一些,备忘。有什么不对的地方,欢迎指正。

 

1 dsjob语法

Command Syntax:

dsjob [-authfile <authfile> | -file <file> <domain> <DataStage server> | -domain <domain> -user <user> -password <password> -server <DataStage server>] | -domain <domain> [-user <user>] -server <DataStage server>

<primary command> [<arguments>]

Valid primary command options are:

-run

-stop

-lprojects

-ljobs

-linvocations

-lstages

-llinks

-projectinfo

-jobinfo

-stageinfo

-linkinfo

-lparams

-paraminfo

-log

-logsum

-logdetail

-lognewest

-report

Technorati 标签:

-jobid

-import

Status code = -9999 DSJE_DSJOB_ERROR

2 脚本示例

dsjob所在的目录为(据实况而定):/mistel/IBM/InformationServer/Server/DSEngine/bin/dsjob

2.1 运行job

运行job,并把日志写在/DS/DSLogs/目录下,每天一个新的文件。

dsjob -run -mode NORMAL -jobstatus dstage1 DD_Test >> /DS/DSLogs/job_run_` date +%Y%m%d`.log

2.2 重置job

当job的状态为“为编译”,“终止”等时,需要重新编译才可以运行。

dsjob -run -mode RESET -wait dstage1 DD_Test >> /DS/DSLogs/job_init_` date +%Y%m%d`.log

更多例子(dstage1项目下的 DD_Test job):

dsjob -run -mode NORMAL -jobstatus dstage1 DD_Test >> /DS/DSLogs/job_run_` date +%Y%m%d`.log

dsjob -report dstage1 DD_Test >> /DS/DSLogs/job_run_` date +%Y%m%d`.log

3 问题解决

3.1 dsjob:command not found

执行脚本时,可能出现dsjob命令未找到的错误提示,解决办法有几种。

3.1.1 解决一

即每次调用dsjob命令前,都把dsenv中的变量读取一次。命令如下:

source /mistel/IBM/InformationServer/Server/DSEngine/dsenv

3.1.2 解决二

让Linux每次登录时自动执行3.1.1中提到的脚本。即在/etc/profile.d/custom.sh中添加这段脚本。

3.2 较完整的脚本

/test/runJob.sh

#!/bin/bash

########################################

#

# runJob.sh 2012-08-19

# run a job with parameters

#

#######################################

# if the number of input parameters is less than 2,then output the help document and exit

if [ $# -lt 2 ] ; then

cat << HELP

runJob --run a job UASGE: runJob projectName jobName jobParameters

EXAMPLE: runJob dsstage1 DD_Test -param startDT=20120819 -param endDT=20120819

HELP

exit 0

fi

projectName="$1"

jobName="$2"

jobParameters="$3"

#echo $projectName

#echo $jobName

#echo $jobParameters

logdir=/DS/DSLogs #directory to store logs

workdate=`date +%Y%m%d`

#logdir processing.If log folder not exists,create folder.

if [ -d $logdir ]; then

echo "$logdir is exist,continue..."

else

echo "$logdir is not exist,creating $logdir..."

mkdir -p $logdir

fi

#job state processing.If job state is not finished ok,then reset the job

jobsta=$($DSHOME/bin/dsjob -jobinfo $projectName $jobName 2>&1 | awk -F: '/^Job Status/{print $2}')

echo $jobsta

if [ "$jobsta" == " RUN FAILED (3)" -o "$jobsta" == " STOPPED (97)" ];then

echo "Reset before run job $jobname"

$DSHOME/bin/dsjob -run -mode RESET $projectName $jobName >>${logdir}/job_init_` date +%Y%m%d`.log

sleep 5

fi

#run a job

dsjob -run -mode NORMAL $jobparameters -jobstatus $projectName $jobName >> /DS/DSLogs/job_run_` date +%Y%m%d`.log

你可能感兴趣的:(Data)