! //MTB// Src(SHUTDOWN.MTB,MSC) Obj(SHUTDOWN,MSC) !S SHUTDOWN.MTB,MSC !O SHUTDOWN,MSC !L TXX,E !R QMONITOR !=============================================================================== ! C O M M E N T S !=============================================================================== ! This program is meant to be activated in a background partition. ! ! This program loops until the specified time and then shuts down Comet on ! the node where it is run. It does this by killing whatever program is ! running in the first partition on the node, waiting 5 seconds for QMONITOR ! to start running in that partition, and then sending an INTERRUPT message ! to QMONITOR, which tells QMONITOR to RUN QIPL0. (QIPL0 shuts down the node, ! but can only be run from the first partition on a node.) ! ! There are two parameters that can be set via symbolic constants: ! ! ShutdownTime$ is a string that contains the desired shutdown time ! (in 24-hour format, earlier than midnight). The default value is ! "23:00". ! ! Seconds is the number of seconds for this program to pause between ! each check of the clock. The default value is 30. (Setting this ! value too low could result in degraded performance on the node, ! while setting this value too high could result in a shutdown time ! well beyond the intended time.) ! ! If you want to start this program each time Comet is started, include ! the following statement in your QSTARTX program: ACTIVATE "","SHUTDOWN" !========================================================================================= ! S E T S T A T E M E N T S !========================================================================================= SET ShutdownTime$ = "23:00" ! When to shutdown SET Seconds = 30 ! Number of seconds to pause !========================================================================================= ! D A T A S E C T I O N !========================================================================================= LENGTH 80 & LOCAL A$ LENGTH 6.0 & LOCAL PauseTime !========================================================================================= ! C O D E S E C T I O N !========================================================================================= PauseTime = Seconds * 18 ! Calculate the pause factor DO ! Start loop A$ = DSTAT("CL1") ! Refresh TIME$ IF TIME$ > ShutdownTime$ THEN BREAK ! See if it's time to shutdown PAUSE PauseTime ! Wait before checking again LOOP ! Continue looping ! The program gets to this section when TIME$ is greater than the ShutdownTime$ ! Find the first partition number on this node and convert ! the number to a partition name A$ = DSTAT("X00") A$ = STRIP(STR(HEXDEC(SUB(A$,50,1)+SUB(A$,49,1)))) KILL A$ ! Kill any program running in first partition PAUSE 90 ! Wait 5 seconds for QMONITOR to setup MESSAGESUB MESSAGE$ = 'QIPL0' ! Use MESSAGE$ to tell QMONITOR to run QIPL0 INTERRUPT A$ ! Interrupt the first partition and shut down the node END