How to set time out period for a job run?

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
Vijay Kumar
Participant
Posts: 59
Joined: Sat May 29, 2004 12:31 am
Location: Pune

How to set time out period for a job run?

Post by Vijay Kumar »

Hi,
Can we set timeout period for a job run?
For example if we define a timeout period of 10min and if the job runtime takes more than 10min the job should abort and mail has to be sent abt the status..
Any pointer to accomplish this sort of task???

Job can be either a serverjob or parallel job or sequencer...


Thanks & Regards
Vijay Kumar
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

I also had a similar requirement, check this post

viewtopic.php?t=96797
Success consists of getting up just one more time than you fall.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You can get a job's last start time and status from places such as the dsjob command line or within a BASIC program. If the 10 minute time limit is exceeded then you can issue a STOP command to that job. The approach you take is dependant upon where you wish to implement this logic - outside of the DataStage environment or inside.
Vijay Kumar
Participant
Posts: 59
Joined: Sat May 29, 2004 12:31 am
Location: Pune

Post by Vijay Kumar »

I want to stop the DS job if it exceeds the time period and i want to implement this from the job control which executes a series of jobs.

All the statements in the Job controler are executed one after the other. After executing the DSRun statement and before the DSRun statement returns its status, I want to calculate the time difference. If the time diff exceeds the thershold I want to abort the job.

Can any one tell me how to accomplish this or some BASIC code to do it.

Thanks in advance.
Regards
Vijay Kumar
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Vijay,

you cannot do this type of functionality directly from the sequence which starts the job. Since it is waiting for the job it called to finish it isn't able to simultaneously check for it running too long.

I would have your sequence start two actions in parallel, your job and a Routine Activity which would contain some basic code based on what I've written below. Please note that this code was typed straight in here so there is only a 0.1% chance that it will compile and a 0.001% percent chance that it will work - but it should be enough to show how to approach solving your problem.

Code: Select all

Handle = DSAttachJob(<JobToMonitor>,DSJ.ERRFATAL)
Timeout = 600 ;** seconds
StartTime = TIME()
Finished = 0
LOOP UNTIL Finished
   JobStatus = DSGetJobInfo(Handle,DSJ.JOBSTATUS)
   IF JobStatus <> DSJS.JOBRUNNING
   THEN
      Finished = 1
   END
   ELSE
      SLEEP(30) ;** wait for 30 seconds before doing anything
      CurrentTime = TIME()
      IF CurrentTime < TIME() THEN RunTime = (60*60*24)-StartTime+CurrentTime
                                          ELSE  RunTime = CurrentTime - StartTime
      IF RunTime > Timeout
      THEN
         *******************
         ** Stop the job here **
         *******************
         Dummy = DSStopJob(Handle)
         Finished = 1
      END
   END
REPEAT
Vijay Kumar
Participant
Posts: 59
Joined: Sat May 29, 2004 12:31 am
Location: Pune

Post by Vijay Kumar »

Hi ArndW,

Thanks a lot for ur code and suggestion.
I think I can implement this sort of logic for entier job sequence time out instead of individual job in the sequencer. Any how I will do it.

Regards,
Vijay Kumar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Another option is to leverage your Enterprise Scheduler... if you have one.

For example, we use Control-M to run jobs or series of jobs under our custom job control. Besides the boundries we've defined within our job control, we also have a fall back - Control-M. It is simple for it to monitor the runtime of a 'job' and do something when it exceeds a fixed time. We have it page out when an outer 'boundary box' has been exceeded so that someone can look at it and decide what to do. No sense killing it at 10 minutes if it was going to finish in 10 minutes and 5 seconds. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply