Background information about a job

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Background information about a job

Post by pandeesh »

Hi,

If we run a job and click Job-->Cleanup resources, we will get the pid for that particular job.
if its a parallel job, i have seen some jbname.fifo process.
Issuing LIST.READU is similar to Job-->Cleanup resources?
I dont think so. If not whats the equivalent command for that in DS Administrator,
The real reason for why i am asking is , i want to write a BASIC routine for stopping a job(server or px).
We can simply stop it in director.
SOmetimes, the jobs are not getting stopped.
My requirement is i will pass the jobname to the routine.
It should stop that job.

Please help me.

Thanks
pandeeswaran
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

LIST.READU is exactly the command that fills the locks area of Cleanup Resources.
Last edited by ray.wurlod on Mon Apr 16, 2012 2:46 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

When a server/px job is running, if we issue LIST.READU , will there be any entry in the name of that particular running job?
But i guess, the entry will not be exactly in the same name as the job, but something like DSD.*.
Please correct me if i am wrong.
Because i want to find the way to stop a job using routine.

Thanks
pandeeswaran
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

DSAttachJob()
DSGetJobInfo()  ;* check status is DSJS.RUNNING
DSStopJob()     ;* issue stop request
DSDetachJob()
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Thanks Ray!!

It works for all the jobs which are stoppable in director.
But there are some jobs which i am not able to stop in director.
Even i have tried with this routine.
Even though the routine returns 0 code, the jobs are not being stopped.
My code is:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 

***CallingProgName = DSJ.ME 

Jobname = Arg1

JobHandle = DSAttachJob(Jobname, DSJ.ERRNONE) 

STATUS = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)

Call DSLogInfo("the status is" : STATUS,"")

if STATUS = "0"

then

PRINT "The job is currently running"

stoperr = DSStopJob(JobHandle)

if stoperr = 0
then
PRINT "the job stopped successfully"
END
else
PRINT "Invalid Job handle"
Ans=2
END

END
ELSE

PRINT "The job is not running currently"
Ans=1
END

Call DSDetachJob(Jobname,DSJ.ERRNONE)

Ans=0
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

For those jobs, which i am not able to stop i have noticed that there's a process called RT_CONFIGXXXX WHERE XXXX is a job number.
So, what i have planned is getting the job number for that particular process and apend that to RT_CONFIG.

Then using FINDSTR find the INODE number and then clear that.

But i am not able to get the job number:

the code i have tried is:;

Code: Select all

Command = "SELECT JOBNO FROM DS_JOBS WHERE NAME=':Arg1:'"

Call DSExecute("TCL",Command,Output,Result)

Call DSLogInfo("The output is" :Output,"")

Ans=0
But in DS Administrator client, we used to click respond option.
In script How we can do that?

i am getting the output as:

Code: Select all


+DSLogInfo called from : 
Message to be logged is...
> The output isSQL
Please help me to extract the jobno alone.

thanks
pandeeswaran
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Provide the semi-colon that is required to terminate a DataStage/SQL statement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Hi Ray,

I am executing the below code:

Code: Select all

Command = "SELECT JOBNO FROM DS_JOBS WHERE NAME=':Arg1';"
Am i missing any quotes over there?

Evn if i pass valid job name to Arg1 , the routine says 0 records listed.

Please help me.

thanks
pandeeswaran
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, you're missing quotes. Please try to diagnose it yourself (anxious to help you to learn, here).

We'll help if you really truly can't solve it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Thanks ray!

Finally, the below is the routine which stops the jobs which can't be stopped via director.

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 

***CallingProgName = DSJ.ME 

Jobname = Arg1

JobHandle = DSAttachJob(Jobname, DSJ.ERRNONE) 

STATUS = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)

Call DSLogInfo("the status is" : STATUS,"")

if STATUS = "0"

    then

       PRINT "The job is currently running"

       stoperr = DSStopJob(JobHandle)

         if stoperr = 0
          then
              STATUS = DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)
                   if STATUS <> 0
                  then
                    PRINT "the job stopped successfully"
                    Ans=0
                  END
                    else

                            command = 'ps -ef | grep ':Jobname:' | grep -v grep | cut -d " " -f4 | head -1'


                            Call DSExecute('UNIX',command,output1,Result)

                            Call DSLogInfo("the pid is" :output1,"")
  
                                  if output1 = ""
 
                              then

                                PRINT "No processes for the mentioned job"
                                PRINT "Stop unsuccessful"

                                Ans = 3
           
                              END

                                  ELSE
                                     
                                     out = Convert(@FM,"",output1)

                                       cmd = 'kill -9 ':out:''
                                       Call DSExecute('UNIX',cmd,output2,RC)

                                       Call DSLogInfo("the output2 is" :output2,"") 

                                       Call DSLogInfo("the RC is" :RC,"")

                                      if RC = 0
                                      then

                                       PRINT "Kill successful"
                                       PRINT "Job successfully stopped"

                                      Ans=0

                                      END
            
                                        ELSE

                                       PRINT "Unable to stop"
                                           Ans=1
  
                                      END
                              END
                   END

         END

      ELSE

        PRINT "Job failed to stop"

      END

END

ELSE

PRINT "The job is not running currently"
Ans=1
END

Call DSDetachJob(Jobname,DSJ.ERRNONE)

Ans=0
Thanks
pandeeswaran
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Post by fmou »

cmd = 'kill -9 ':out:''
That's pretty heavy-handed method. FYI you can also write a shell script to kill those un-killable jobs. Make your code simpler.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DSDetachJob() takes a single argument (not two) and that needs to be a job handle, not a job name.

If you must use kill, make it more gentle, maybe -15 so that the job gets some grace time to close files, release locks, etc. SIGKILL (-9) can leave locks.

Your other problem, for parallel jobs, is that of cleaning up all the processes in the job. These must be stopped in the correct order; player processes, then section leaders and finally the conductor process. Your code pays no attention to that.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

pandeesh wrote:Finally, the below is the routine which stops the jobs which can't be stopped via director.
<snip>
1)could anyone please tell me where to place this code in Datastage and from which stage we can call this routine?

2)what is meant by Ans=1 and Ans=0
Post Reply