Page 1 of 2

Call job each 30 minutes

Posted: Tue Dec 19, 2006 3:32 pm
by fmartinsferreira
I need to make a job that should be called each 30 minutes.

I'm thinking to make a "job batch" and make a loop to call it each 30 minutes, does anyone has any suggestion? :)

Regards,

Fernando

Posted: Tue Dec 19, 2006 3:48 pm
by narasimha
Another option, If you have a external scheduling tool like Contol-M,yada, yada...
You can schedule it there so that the job runs every 30 minutes.
I find this the easiest method :)

Posted: Tue Dec 19, 2006 3:49 pm
by chulett
You could build a Sequence job with the Loop stages that runs your job and sleeps for X inside each iteration.

Posted: Tue Dec 19, 2006 5:15 pm
by ray.wurlod
What happens if the job needs 35 minutes to run?

You need to insert a check to determine whether the job is already running.

Posted: Tue Dec 19, 2006 5:35 pm
by chulett
Then you just need a smarter sleeper. I wasn't going to add all the gory details, just put forth the general (very) high level concept. :wink:

As an example, I just built one that needs to run over the course of the day and run a series of jobs 'every five minutes'. At the end of each run, regardless of runtime, it sleeps until the next 5 minute mark on the clock. Generally it comes in well under that, but if it does run over then the next 5 minute mark on the clock is the sleep target.

Posted: Tue Dec 19, 2006 5:50 pm
by ray.wurlod
Quite.

Create a routine. Use the fact that the SLEEP statement has two syntaxes - one that sleeps for a given number of seconds, the other that sleeps until a particular clock time. Being in a routine, it is easy to calculate the next 30 minute point.

Posted: Tue Dec 19, 2006 6:35 pm
by DSguru2B
if memory serves me right you would use the 'NAP' command inside the routine. And the NAP will put the routine to sleep for milliseconds.

Posted: Tue Dec 19, 2006 10:29 pm
by ray.wurlod
Not NAP for sleeping up to 30 minutes! :shock:

Posted: Tue Dec 19, 2006 11:43 pm
by DSguru2B
Yea your right, but do we have a SLEEP in Basice. Excuse my ignorance.

Posted: Wed Dec 20, 2006 12:29 am
by chulett
Yes, we do. I'm interested in Ray's statement re: two syntaxes... I see no evidence of the ability of being able to sleep until a particular clock time. Where would that be documented?

I went thru some gyrations to compute the next time to sleep to and how many seconds from now that was, hence the interest. :wink:

Posted: Wed Dec 20, 2006 4:10 am
by ray.wurlod
SLEEP hh:mm

Not documented in DataStage BASIC manual.

Been around since the early days of UniVerse, but not documented in UniVerse BASIC manual either.

One of those undocumented features no-one seems to have a list of.

Posted: Wed Dec 20, 2006 7:06 am
by fmartinsferreira
more information:

- I don't have a external scheduling tool like Contol-M
- The job do not spend more than 2 minutes

How the question here is very urgent, than I make a "job batch" and put in a for and a sleep. :oops: After I will change this! :)

But the "SLEPP 00:30" doesn't work here, well I have the version 7.5.2.

Regards,

Fernando

Posted: Wed Dec 20, 2006 7:48 am
by DSguru2B
I think the two sleep syntaxes that Ray is referring to is Sleep n where n is the number of seconds and the other one that he mentioned. But i am not sure about the syntax of SLEEP HH:MM. I am trying to test it but no matter what i put in HH or MM , for some reasons it just sleeps for that amount of seconds.

Posted: Wed Dec 20, 2006 7:52 am
by DSguru2B
As for fmartinsferreira, you can use

Code: Select all

SLEEP 1800
to sleep for 30 minutes.

Posted: Wed Dec 20, 2006 8:05 am
by fmartinsferreira
DSguru2B wrote:As for fmartinsferreira, you can use

Code: Select all

SLEEP 1800
to sleep for 30 minutes.
Thats work, but I was trying "SLEPP 00:30" too like Ray talked. :)