Delay or Wait in Job Sequence

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
banactp
Participant
Posts: 52
Joined: Tue Feb 22, 2005 2:55 pm

Delay or Wait in Job Sequence

Post by banactp »

Does anyone have any suggestions as to how I could incorporate a variable-length delay into a job sequence?

Specifically, what I'm trying to do is start a job sequence at a random time on a particular day, run up to the last activity in the sequence at normal speed, then delay execution of that last activity until 2:00 AM the next day.

Assume I know the time and date I started the sequence because I've passed that in as a string-type sequence parameter. Don't worry about special situations such as running through midnight.

Any ideas?

TIA,

tpb
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Use sleep or nap.
banactp
Participant
Posts: 52
Joined: Tue Feb 22, 2005 2:55 pm

Post by banactp »

Thanks for your prompt reply!

:?: The problem using sleep() is how to calculate the number of seconds.

I'd have to know the difference in seconds between 0200 the next day and now. "Now" is a known quantity, but how would you go about calculating the desired start time? All the nice time and date functions that are available inside a parallel job aren't available to the sequence.

tpb
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

As you are using a sequence, you can always write a routine with IConv / OConv to get this done.
banactp
Participant
Posts: 52
Joined: Tue Feb 22, 2005 2:55 pm

Post by banactp »

Great idea - just what I needed.

Thanks for your help!
banactp
Participant
Posts: 52
Joined: Tue Feb 22, 2005 2:55 pm

Post by banactp »

:? Well, it looks as if I was a bit premature in my celebration. At least I learned something new today (IConv).

Sleep cannot be used in expressions, which is where I was planning to use it (as the condition for a trigger to the next stage.)

So I am back to step one - how can I force a processing delay of arbitrary length between jobs in a parallel job sequence?

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

Post by chulett »

Still think sleep would be your best bet. Write a routine to do the sleeping and use a Routine Activity stage to run it rather than trying to delay in the trigger.

It could even check the current time or job start time as an argument and sleep a computed length of time, I would think.
-craig

"You can never have too many knives" -- Logan Nine Fingers
banactp
Participant
Posts: 52
Joined: Tue Feb 22, 2005 2:55 pm

Post by banactp »

Excellent!

So, now I've learned two things today (at least), the most important of which is:

You can use server routines to control a parallel job sequence!

Thanks for your assistance!

tpb - DataStage newbie
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The SLEEP statement has two formats.

Code: Select all

SLEEP seconds
SLEEP hh:mm
But the second format only works within a day. If hh:mm is in the past, SLEEP does not wait. To sleep until 02:00 you need to resort to something like:

Code: Select all

SLEEP 23:59
SLEEP 120
SLEEP 02:00
Or, of course, you can calculate the number of seconds

Code: Select all

SLEEP 86400 - Time() + 7200
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
banactp
Participant
Posts: 52
Joined: Tue Feb 22, 2005 2:55 pm

Post by banactp »

I was unaware of the "Sleep HH:MM" format - how did you find out about it?

It is not in the documentation that is displayed when the menu bar Help option is selected from within DataStage. At least, that's not the case with my installation.

tpb
DataStage newbie
Post Reply