Page 1 of 1

Run a job without waiting to complete

Posted: Tue Feb 27, 2007 2:19 am
by PeterPol
Hi all,

We have build a sequence with a loop that must be run a job every hour. Each running job has it's own unique invocation id to make it possible that the same job can run twise (or more ) at the same time.

Each hour the job will be started even if the previous job is still running.

After starting the loop in the seqeunce, the job will be runnning. Now we don't want to wait untill the job is finished otherwise the job can not start the next hour because the seqeunce is still be waiting to finish the previous job run.

So the qeustion is: How can we run a job without waiting to be finished.

Posted: Tue Feb 27, 2007 2:28 am
by kumar_s
Call the job using dsjob command without -wait option.

Posted: Tue Feb 27, 2007 7:10 am
by chulett
That's the answer if the Sequence job itself is what must be started without waiting - and the Sequence is multi-instance. It was hard to tell from your post, but are you asking how to do this for a job that the Sequence itself runs? :?

Posted: Tue Feb 27, 2007 8:28 am
by PeterPol
No, the job in the seqeunce must be started witout waiting..

How can you start a Comand Line interface commando dsjob in a seqeunce?

I just wan to run the job without waiting to finish.....

Posted: Tue Feb 27, 2007 8:36 am
by ArndW
I'm not sure why you can't work around the issue of waiting for the job to finish in the sequence, but yes, you can call a command stage and issue the appropriate "dsjob -run" command from a sequence.

Posted: Tue Feb 27, 2007 9:15 am
by PeterPol
This job seqeunce is the first job in my process to run all other processes after each hour. But when a process is still busy. The first job seqeunce must start all other processes with a new invocation id.

The problem is if a job is started in the seqeunce the job seqeunce will wait until the job has finshed and wait than an hour.

:roll:

Posted: Tue Feb 27, 2007 9:35 am
by ArndW
In that case you should write a "master" sequence which calls the first job/sequence without waiting. I see two ways to do this for you:

1 - use the command to run "dsjob -run -mode normal {job} {project}"

2 - use a job activity to start the job in a sequence. Then look at the job control for the BASIC code that has been generated and you can see where to remove the WAIT. Note that changes disappear when you recompile, so this is not the recommend route.

Posted: Tue Feb 27, 2007 3:06 pm
by ray.wurlod
You can use an Execute Command activity to execute dsjob, as others have noted.

You can also use a Routine activity to call UtilityRunJob, or a routine of your own that submits the run request and exits without waiting for the job to finish.

Code: Select all

FUNCTION RunJobNoWait(JobName, InvocationID)
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF

hJob = DSAttachJob(JobName : "." : InvocationID, DSJ.ERRNONE)

Ans = DSGetJobInfo(hJob, DSJ.JOBNAME)
If Ans >= DSJE.NOERROR
Then 
   Ans = DSRunJob(hJob, DSJ.RUNNORMAL)
End

ErrCode = DSDetachJob(hJob)

RETURN(Ans)

Posted: Wed Feb 28, 2007 1:11 am
by PeterPol
Thanks
The writen routine works for my problem. :D

Posted: Wed Feb 28, 2007 1:17 am
by DSguru2B
Time to mark your post as 'Resolved'.