Datastage jobs and Unix Environment

How to run DataStage jobs via Unix

Running the jobs

dsjob command allows to run, stop and see log details of  DataStage jobs:

Directory “opt/IBM/InformationServer/Server/DSEngine/bin”

#dsjob -run {Projectname} {job-name}

or

#dsjob -run -param {parametername=value} –mode VALIDATE/RESET/RESTART {Projectname} {job-name}

Valid primary command options are:
-run
-stop
-lprojects
-ljobs
-linvocations
-lstages
-llinks
-projectinfo
-jobinfo
-stageinfo
-linkinfo
-lparams
-paraminfo
-log
-logsum
-logdetail
-lognewest
-report
-jobid
-import

Status code = -9999 DSJE_DSJOB_ERROR

 

Command options for Running jobs
dsjob -run
[-mode]
[-param]
[-warn]
[-rows]
[-wait]
[-opmetadata
[-disableprjhandler]
[-disablejobhandler]
[-jobstatus]
[-userstatus]
[-local]
[-useid]

Example :

#dsjob -jobinfo  project_name job_name

 

To stop the  job

dsjob –stop  project_name  job_name|job_name.invocationid

How to kill DataStage jobs via Unix

Sometimes DataStage jobs get stuck for some reasons and could not be stopped gracefully. Following are the steps kill the jobs exclusively

Steps:

  1. Login to DataStage server via putty
  2. use the ps-ef command to list the processes running on server’s
# ps -ef | grep <userid>

this command will list all the process running
  1. Process matching dsapi_slave keyword are DS jobs
  2. note down the PID number of process
  3. kill the jobs using following command.
# kill -9 pid

Example:

#ps -ef | grep dsadm

UID PID PPID C STIMETTY TIMECMD

dsadm 3384 1215 0 10:15:36 ? 0:00 dscs 4 5600 0
dsadm 3385 1184 0 10:15:34 ? 0:02 dsapi_slave 7 5 0
dsadm 2302 11215 0 May 04 ? 0:00 dscs 4 3500 0
dsadm 7603 1202 0 May 04 ? 0:03 dsapi_slave 7 5 0

To kill the process

Kill -9 7603

Scheduling DataStage jobs using crontab

The Crontab utility allows scheduling the jobs on Unix /Aix environment. While adding the jobs we could define the frequency and time.

Adding a job to crontab:

$ crontab -e

this command will open the editor where jobs can be defined

For example w e need to run the job on weekdays during the working hours 9 a.m – 6 p.m.

Add the follwing line to editor and save it .

00 09-18 * * 1-5 /home/bin/dsjob -run Prj1 job_1

 

Specifying Time-related properties:

  • 00 – 0th Minute (Top of the hour)
  • 09-18 – 9 am, 10 am,11 am, 12 am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm
  • * – Every day
  • * – Every month
  • 1-5 -Mon, Tue, Wed, Thu and Fri (Every Weekday)

 

Scheduling job to run multiple times a day

To run a job at 9 am and 10 am put hours with delimiter comma.

00 09,10 * * 1-5 /home/bin/dsjob -run Prj1 job_1

To view the list of jobs scheduled.

$ crontab -l
00 09-18 * * 1-5 /home/bin/dsjob -run Prj1 job_1
00 09,10 * * 1-5 /home/bin/dsjob -run Prj1 job_2

 

To schedule Every minute:

* * * * * CMD

 

To schedule daily

@daily   /home/bin/dsjob -run Prj1 job_2

this command  will schedule the job to run 00:00 daily

 

To schedule monthly

@ monthly  /home/bin/dsjob -run Prj1 job_2

this command will schedule the job to run t 00:00 on 1st of every month

 

for every 15 minutes

*/10 * * * * / home/bin/dsjob -run Prj1 job_2

Datastage Versions:

This article pertains to DataStage version 8.1,8.5,8.7,.9.1,9.5,11.3 and 11.5

Share this post

Leave a Reply