Data Stage can send msg if Job is running longer

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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Longer than "normal" is tricky until you have some sense for how long "normal" is!

If you have one job controlling another, then the control code is likely to have statements of the form:
. ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
. ErrCode = DSWaitForJob(hJob1)

In this case, the controlling job sleeps until the controlled job signals that it has finished. You can change the code to a "busy wait" - a loop that checks periodically that the job is still running. In this loop you could call DSSendMail with your "over time" message.

. Equate MAXTIME To 3600 ; * one hour, for example
. ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
. Sleep 15 ; * allow time to get started
. StartTime = Time()
. JobStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
. Loop
. While JobStatus = DSJS.RUNNING
. If (Time() - StartTime) > MAXTIME
. Then
. GoSub OverTime ; * write your own!
. End
. Sleep 10
. JobStatus = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
. Repeat

Note that this example does not take into account running through midnight, but this is easy enough to handle. Or simply increment a count of seconds executed by 10 each time through the loop.


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Post Reply