Running Jobs from Unix script & understanding status

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
gdheatley
Participant
Posts: 10
Joined: Mon Aug 11, 2003 2:52 pm

Running Jobs from Unix script & understanding status

Post by gdheatley »

I am envoking my datastage job using a unix shell script. Within the unix shell I am calling the data stage job using dsjob along with the required parameters. One of the parameters I am using is jobstatus. When the script runs, the data stage job is executed, and the messages I recieve back to the command line are as follows:
Waiting for job...
Finished waiting for job
Job Status : (1)

Status code = 1
Which makes total sense. However when I remove the jobstatus parameter (as I want to specifically query once job is completed) the message I recieve back to the command line is as follows:
Status code = 0
Can anyone tell me what is generating this status code? And why it should be different to the job status code now?

The following is the code being used with the jobstatus parameter and then after it the code without it:

with:

Code: Select all

 
dsjob -server $DS_Server -user $DS_User -password $DS_Pwd -run -mode NORMAL -par 
am Staging_Dir=$Staging_Dir -param Outbound_Dir=$Outbound_Dir -param RDS_Version 
=$RDS_Version -param RDS_Hierarchy=$RDS_Hierarchy -jobstatus $DS_Project $DS_Job 
without:

Code: Select all

 
dsjob -server $DS_Server -user $DS_User -password $DS_Pwd -run -mode NORMAL -par 
am Staging_Dir=$Staging_Dir -param Outbound_Dir=$Outbound_Dir -param RDS_Version 
=$RDS_Version -param RDS_Hierarchy=$RDS_Hierarchy $DS_Project $DS_Job 
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You are not supposed to use jobstatus and run a job at the same time. Look here for an example:
viewtopic.php?t=85578
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The exit status of the dsjob command without its -jobstatus option is exactly that, the exit status of the dsjob command. Even if the job failed in DataStage, the dsjob command (which requested the run) completed successfully, and will return 0.

The -jobstatus option not only produces a job status report when the job finishes, it also changes the behaviour of the dsjob command so that its exit status is that of the job whose run was requested. This means that you don't have to request the job status explicitly and parse out the information that you seek.

Source code for dsjob is to be found in Appendix A of the Server Job Developer's Guide. It's not 100% up to date, but will give you some idea of what's going on.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply