Page 1 of 1

Keep Sequencer waiting to trigger a job at a particular time

Posted: Thu Mar 21, 2019 5:40 am
by suja.somu
A Sequence job is scheduled to trigger daily at 10 PM and it runs multiple jobs . There is one Parallel DataStage job(say X) in that sequence that has to run at a particular time at 2 AM. Even if the Preceding jobs finish early before 2 AM, the sequence job should keep running and wait till 2 AM to trigger the job X . If the Preceding jobs finish later than 2 AM, the sequencer should exit . How I can do this ?

Posted: Thu Mar 21, 2019 9:51 am
by ray.wurlod
Check whether the time is after 10PM and earlier than 2AM (e.g. User Variables activity). If it is, execute a sleep command to wait until 02:00 then run the job. If it is after 2AM, then bypass that logic. Both streams of logic end up in the same Any sequencer.

Re: Keep Sequencer waiting to trigger a job at a particular

Posted: Fri Mar 22, 2019 3:25 am
by ith0021
Ray provided the solution..

Another option would be, take out the 'X' job from the main sequence job.
Schedule the main sequence job to run at 10 pm and once it is completed touch 'mainsequencejob.Done' file.
Also schedule the 'X' job to run at 2 AM and have a wait for file activity to check the 'mainsequencejob.Done' file, if it is there continue to run the 'X' job or dont execute the job.

Posted: Fri Mar 22, 2019 9:40 am
by suja.somu
Thanks Ray and Karthik for the response.

Currently I am checking the time in a shell script and executing the Job, it works fine. I want to simplify the design to get rid of shell script and also I don't want to use touch or done file.

I am more inclined towards Ray solution. Could you please elaborate on the first step : how to check time in User Variable activity?

Also , Sleep HH:MM in the execute command stage failed with a error " invalid time interval "

Even on the Linux box , the error is as below
sleep: invalid time interval `02:00'


Version: DataStage 11.5 on RHEL LINUX

Please help.

Posted: Sat Mar 23, 2019 2:05 am
by chulett
Just going to address the "Also". That sleep sleeps for an amount of time, by default in seconds, not until a specific time, which is why you got that interval error. So you would need to get the current time as Ray noted and then compute the number of seconds (or minutes) until your target time, then sleep for that interval.

Posted: Mon Mar 25, 2019 5:38 pm
by ray.wurlod
Within DataStage BASIC programming language SLEEP hh:mm is permitted, so you can effect this with a very simple one-line routine.

(Avoid Execute Command - every time you use it you carry the overhead of opening a new shell and starting any processes required in it.)

Posted: Mon Mar 25, 2019 5:42 pm
by ray.wurlod

Code: Select all

Oconv(@TIME, "MT") >= "22:00" Or Oconv(@TIME, "MT") <= "02:00"
System variable @TIME is set when the job starts. If that's not what you want, the Time() function returns the system time when invoked.

A user variable with the above derivation will return 1 (true) or 0 (false), which you can test in any downstream activity.

Posted: Tue Mar 26, 2019 6:27 am
by chulett
Ah yes... forgot about the whole BASIC versus UNIX aspect of sleeping. :wink: