[comp.os.vms] RUN/DETACHED/TIME_LIMIT=n

rlb@rtpark.rtp.ge.COM (Bob Boyd 8*565-3627 22-Oct-1987 1705) (10/23/87)

Perkins@Arc.CDN had a question about running an image with a time limit.

Looking at the HELP RUN PROCESS I see there is /TIME_LIMIT=n.

I think a workable solution is the following:

$ RUN/DETACHED SYS$SYSTEM:LOGINOUT.EXE/INPUT=mydisk:[mydir]myprog.com -
	/OUTPUT=mylog.log-
	/PROCESS_NAME=TIMED_JOB -
	/TIME_LIMIT=n ! as calculated for your needs

Then in MYPROG.COM
$ ON ERROR THEN $ SUBMIT CLEANUP.COM ! I don't know if this will work --
$!	just suggesting it as a possibility.
$ RUN MY_IMAGE
$ SUBMIT CLEANUP.COM  ! you should get a few extra seconds of cpu time

If the last line of the above example won't do it, then you could have another
process sit and watch it and when it goes away, then do the cleanup.
Here is how to do it: 

$ SPAWN/NOWAIT @BUSYCHECK TIMED_JOB 0-0:1:0.0  SUBMIT CLEANUP.COM


-------------------------------------------------------------------------
$! busycheck.com -- monitor a process to see if it's alive
$!
$!  p1 -- process name to be monitored
$!  p2 -- delay time in between checks.
$!
$!  p3 - p8 command and qualifiers to execute when done
$!
$ if p1.eqs."" then inquire p1 "Process name"
$ if p2.eqs."" then p2 := 0:0:5.0
$ proc_name = p1
$ delay = p2
$ !  
$  ctx = -1
$LOOP:
$  pid = f$pid(ctx)
$  proc_name = f$edit(f$getjpi(pid,"prcnam"),"trim")
$  if F$LOC(P1,proc_name).ge.f$len(proc_name) then goto LOOP
$  new_cpu = f$getjpi(pid,"cputim")
$ ! 
$WAIT_LOOP:
$ wait 'delay'
$ new_cpu = f$getjpi(pid,"cputim")
$ if $status then $ goto WAIT_LOOP
$
$!finish up here
$ 'p3' 'p4' 'p5' 'p6' 'p7' 'p8'
$ !
$ EXIT
$ !
$!Last Modified:  22-OCT-1987 17:34:37.31


-----------------------------------------------------------------
 Bob Boyd                     Usenet:    rlb@rtpark.rtp.ge.com
 GE Microelectronics Ctr.     Voice:     (919)549-3627
 POB 13049, MS 7T3-01         GE DIALCOMM:  8*565-3627
 RTP, NC 27709-3049           GE DECnet: RTPARK::RLB