Page 1 of 2

REXX to find out if a job is completed

PostPosted: Tue Sep 13, 2016 9:52 pm
by cvcv
Hi, I’ve created a little utility to generate and submit (using REXX QUEUE/submit) a bunch of DB2 Load jobs (each job loads a specific db table).

Right now, every job gets submitted one after the other without waiting for the previous job (submitted) to be completed.

I’m trying to think about creative ways, using REXX, to force the utility to wait for the previous job to finish before submitting the next one.

The only thing I could come up with is to check if a Load job’s input dataset is “locked” (by the job itself), if that’s even possible, and wait until it is “free” for the next job to be submitted. But the problem with this is that the second job could potentially start before the first one has the time to open the file. Might not work.

Any ideas?
Thanks

Re: REXX to find out if a job is completed

PostPosted: Tue Sep 13, 2016 10:58 pm
by enrico-sorichetti
since You build the jobs Yourself the easiest solution is
store all the jobs in a PDS
add to each job a step ( as the last step ) to submit the next job

Re: REXX to find out if a job is completed

PostPosted: Tue Sep 13, 2016 11:24 pm
by cvcv
ok thanks for the good idea. That was my goal though.. to not save the jobs generated. I guess I would have to do that if I want to submit the jobs one by one.

Thanks

Re: REXX to find out if a job is completed

PostPosted: Wed Sep 14, 2016 1:17 am
by enrico-sorichetti
and the last job might as well delete the PDS used for the whole shebang

Re: REXX to find out if a job is completed

PostPosted: Wed Sep 14, 2016 3:06 am
by NicC
Or put a TYPRUN=HOLD on all the jobs except the first and a final step of each job but the last to release the next job.

Re: REXX to find out if a job is completed

PostPosted: Wed Sep 14, 2016 1:11 pm
by willy jensen
You can use the SDSF REXX API in a loop to continuously check the jobs progress. More complicated by still an option.
If you go for the PDS option then your dynamically built job stream could have an IEBUPDTE ./ ADD statement in front of each separate job, so that the job stream would build the PDS.

Re: REXX to find out if a job is completed

PostPosted: Wed Sep 14, 2016 7:14 pm
by enrico-sorichetti
You can use the SDSF REXX API in a loop to continuously check the jobs progress.

not the smartest approach IMO, having a tso session waiting for 100 jobs to finish :mrgreen:

Re: REXX to find out if a job is completed

PostPosted: Wed Sep 14, 2016 9:48 pm
by cvcv
Thanks for your help guys, really appreciated

Re: REXX to find out if a job is completed

PostPosted: Wed Sep 14, 2016 11:27 pm
by willy jensen
@enrico
it depends. 100s of jobs, not a good idea.10 or so quick jobs it may be an option. just another tool in the toolbox.

Re: REXX to find out if a job is completed

PostPosted: Thu Sep 15, 2016 12:36 am
by steve-myers
enrico-sorichetti wrote:
You can use the SDSF REXX API in a loop to continuously check the jobs progress.

not the smartest approach IMO, having a tso session waiting for 100 jobs to finish :mrgreen:

Agreed. However, this is a task any scheduling package can do quite well.