Page 1 of 1

How to set time out period for a job run?

Posted: Wed Dec 21, 2005 11:49 pm
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

Posted: Thu Dec 22, 2005 12:22 am
by loveojha2
I also had a similar requirement, check this post

viewtopic.php?t=96797

Posted: Thu Dec 22, 2005 2:58 am
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.

Posted: Thu Dec 22, 2005 4:17 am
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

Posted: Thu Dec 22, 2005 5:30 am
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

Posted: Thu Dec 22, 2005 6:40 am
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

Posted: Thu Dec 22, 2005 8:00 am
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: