$! CLEANSTART_BATCH_QUEUE.COM Empty & start a batch queue $! $! This command procedure removes all entries from a batch queue then $! starts the queue. $! $! P1 = queue name $! P2 = qualifiers for INIT/QUE/BATCH; if not supplied, no INIT/QUEUE/BATCH $! command will be issued against the queue $! $! Created 31-Mar-2003 by Jeremy Begg, VSM Software Services Pty Ltd $! $!****************************************************************************** $ $ set noon $ $ say = "write sys$output" $ $! $! Check that we have a queue name $! $ queue = f$edit(p1,"COLLAPSE,UPCASE") $ if queue .eqs. "" $ then $ say "%CLEAN-F-NOQUEUE, queue must be specified in P1" $ exit 276 $ endif $ $! $! See if we want to INITIALIZE this queue $! $ if p2 .eqs. "" $ then $ iniq = "!" $ else $ iniq = "INITIALIZE/QUEUE/BATCH" + p2 $ endif $ $! $!------------------------------------------------------------------------------ $CLEAN_QUEUE: $! $! See if the queue exists and what state it's in. $! $ stopped = f$getqui("DISPLAY_QUEUE","QUEUE_STOPPED",queue) $ if stopped .eqs. "" $ then $ ! Queue does not exist $ if iniq .eqs. "!" $ then $ say "%CLEAN-F-QUEUEDNE, batch queue ", queue, " does not exist and cannot be created" $ exit 2696 $ else $ ! No need to clean out this queue $ goto INIT_QUEUE $ endif $ else $ if .not. stopped $ then $ say "%CLEAN-W-RUNNING, queue ", queue, " is not stopped" $ endif $ endif $ $! $! Scan for jobs in the queue $! $ qname = f$getqui("DISPLAY_QUEUE","QUEUE_NAME",queue,"WILDCARD") $JOBS_Loop: $ entry = f$getqui("DISPLAY_JOB","ENTRY_NUMBER",,"ALL_JOBS") $ if entry .eqs. "" then $ goto JOBS_End $ jname = f$getqui("DISPLAY_JOB","JOB_NAME",,"FREEZE_CONTEXT") $ jobex = f$getqui("DISPLAY_JOB","JOB_EXECUTING",,"FREEZE_CONTEXT") $ if jobex $ then $ say f$fao("%CLEAN-E-EXECUTING, job !AS (entry !SL) is currently executing and will not be deleted", jname, entry) $ else $ say f$fao("%CLEAN-I-DELETING, deleting job !AS (entry !SL)", jname, entry) $ delete/entry='entry' $ endif $ goto JOBS_Loop $JOBS_End: $ xxx = f$getqui("CANCEL_OPERATION") $! $! If the queue is now idle, stop it $! $ if f$getqui("DISPLAY_QUEUE","QUEUE_IDLE",queue) $ then $ say "%CLEAN-I-STOPPING, stopping idle batch queue ", queue $ stop/next 'queue' $ wait 00:00:01 $ endif $ $ if .not. f$getqui("DISPLAY_QUEUE","QUEUE_STOPPED",queue) $ then $ say "%CLEAN-W-RUNNING, queue ", queue, " is still active after deleting jobs" $ endif $ $! $!------------------------------------------------------------------------------ $INIT_QUEUE: $! $! Initialise the queue and start it $! $ $ 'iniq' 'queue' $ $ start/queue 'queue' $ $ show queue/full/all 'queue' $ $ exit