Page 1 of 1

Background information about a job

Posted: Sun Nov 06, 2011 10:10 am
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

Posted: Sun Nov 06, 2011 11:42 am
by ray.wurlod
LIST.READU is exactly the command that fills the locks area of Cleanup Resources.

Posted: Sun Nov 06, 2011 11:47 am
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

Posted: Sun Nov 06, 2011 6:21 pm
by ray.wurlod

Code: Select all

DSAttachJob()
DSGetJobInfo()  ;* check status is DSJS.RUNNING
DSStopJob()     ;* issue stop request
DSDetachJob()

Posted: Mon Nov 07, 2011 1:56 am
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

Posted: Mon Nov 07, 2011 2:14 am
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

Posted: Mon Nov 07, 2011 2:47 am
by ray.wurlod
Provide the semi-colon that is required to terminate a DataStage/SQL statement.

Posted: Mon Nov 07, 2011 3:19 am
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

Posted: Mon Nov 07, 2011 2:57 pm
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.

Posted: Tue Nov 08, 2011 12:54 am
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

Posted: Tue Nov 08, 2011 12:49 pm
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.

Posted: Tue Nov 08, 2011 3:11 pm
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.

Posted: Mon Apr 16, 2012 11:06 am
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