$! $! EVERYMNTH.JOB $! $! This batch job is run at midnight on the 1st of every month. $! Its purpose is to submit other batch jobs to be run on a monthly $! basis. $! $ verify_mode = 'F$VERIFY(0)' $ GOTO L1$ $!+ EVERYMNTH $! Items to be handled on a monthly basis are done by the EVRYMNTH job. $! This batch job uses the command procedure EVERYMNTH.JOB to perform the $! housekeeping chores of setting and re-submitting the monthly job. The $! actual work is done in the EVERYMNTH.COM command procedure (to allow $! changes without having to resubmit the batch job). The batch job is $! invoked by: $! $! @SYS$MGR_UTIL:EVERYMNTH.JOB opcode $! $! or by: $! $! SUBMIT/NOPRINT/NAME=EVRYMNTH/PARAMETER=opcode - $! SYS$MGR_UTIL:EVERYMNTH.JOB $! $!2 Opcode $! The operation code passed as the first parameter to the EVERYMNTH.JOB $! command procedure determines the action this command procedure takes: $! $! SETUP setup the EVRYMNTH batch job (also deletes any such $! jobs currently in the batch queue). Does not execute $! EVERYMNTH.COM. $! $! ONCEONLY run once (with no re-submittal) usually for a test. $! $! GOGOGO normal operation, re-submit to run next month and then $! execute EVERYMNTH.COM. $!- $! $! Created: 30-Aug-82 Frank J. Nagy Fermilab Accelerator/Controls $! $! Modifications: $! 30-Aug-82 FJN Created from EVERYWEEK.JOB $! 01-Oct-82 FJN Give job high priority in batch queue and raise $! execution priority $! 06-Oct-82 FJN Raised batch job priority $!============================================================================= $L1$: $! $ SET NOON $! $! Test for SETUP run (called as a command procedure) $! or for a ONCEONLY run (no re-submission) $! or for a normal (GOGOGO) midnight run $! - all by looking at parameter P1 $! $ IF P1 .EQS. "ONCEONLY" THEN GOTO DO_MY_THING $ IF P1 .NES. "GOGOGO" THEN GOTO FIRST_TIME_THRU $! $ SET PROCESS/PRIORITY=12 !Raise process's priority $! $ PURGE EVRYMNTH.LOG !Purge old versions of log file $! $! Now get the absolute date of the first of the next month $! $ subr_return := NORMAL_RESUBMIT $ GOTO CALCULATE_DATE $NORMAL_RESUBMIT: $! $! Re-submit to run at midnight on the first day of the next month. $! $ SUBMIT/AFTER='abs_date'/NAME=EVRYMNTH/PARAMETERS=GOGOGO/PRIORITY=28/NOPRINT - SYS$MGR_UTIL:EVERYMNTH.JOB $ SHOW QUEUE/ALL SYS$BATCH $! $DO_MY_THING: $! $ GOTO L10$ $! Here is where the real work gets done. The SUBMIT commands (or @name) $! commands should go in the SYS$MGR_UTIL:EVERYMNTH.COM file. Remember $! that this job is running under the SYSTEM account (UIC [1,4]) as will any $! batch jobs SUBMIT'ed from here or any command files executed from here. $! The current default directory is now: SYS$MANAGER:!!! $! If a batch job must be run under a different user either you can: $! 1. Change the UIC and default directory at the start of the $! command file submitted as a batch job. $! 2. SPAWN a command file off under a different UIC to do you thing $! or SUBMIT a batch job. (Or you can insert a detached process $! RUN command into here). $! Note that the .LOG files for batch jobs submitted from here or detached $! processes SPAWN'ed from here are placed in SYS$MANAGER:. $! $! Changes to command files referenced in here may be made freely. If this $! command file is changed, you must be the SYSTEM user and the very next $! thing you must do is to do a setup run as in "@EVERYMNTH.JOB SETUP" to $! delete any current EVRYMNTH batch job(s) are re-submit so that the new $! version of the command file will be used. This job will also be re-submitted $! after the VAX is rebooted. $! $L10$: $! $ IF VERIFY_MODE THEN SET VERIFY $! ===================== $@SYS$MGR_UTIL:EVERYMNTH.COM $! ===================== $! $ EXIT ! End-of-job for this month $! $! For first time do: @EVERYMNTH.JOB SETUP $! $FIRST_TIME_THRU: $! $! Delete any current EVRYMNTH jobs in the queue $! $@SYS$MGR_UTIL:BATQUEDEL EVRYMNTH $ IF job_time .EQS. "" THEN GOTO NONE_IN_QUEUE $! $! Deleted one pending, resubmit with the absolute time from $! the deleted job. $! $ SUBMIT/AFTER='job_time'/NAME=EVRYMNTH/PARAMETERS=GOGOGO/PRIORITY=28/NOPRINT - SYS$MGR_UTIL:EVERYMNTH.JOB $ SHOW QUEUE/ALL SYS$BATCH $! $ EXIT $! $NONE_IN_QUEUE: $! $! Now get the absolute date of the first of the next month $! $ subr_return := NONE_IN_QUEUE_1 $ GOTO CALCULATE_DATE $NONE_IN_QUEUE_1: $! $ SUBMIT/AFTER='abs_date'/NAME=EVRYMNTH/PARAMETERS=GOGOGO/PRIORITY=28/NOPRINT - SYS$MGR_UTIL:EVERYMNTH.JOB $ SHOW QUEUE/ALL SYS$BATCH $ EXIT $!============================================================================= $CALCULATE_DATE: $! $! Now calculate the absolute date of the first of the next month and place in $! the symbol abs_time. $! $ time = F$TIME() $ this_month := 'F$EXTRACT(3,3,time)' !Name of current month $ months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDECJAN" $ where = F$LOCATE(this_month,months) + 3 $ next_month = F$EXTRACT(where,3,months) !Name of next month $! $! If the next month is January, then increment to the next year. $! $ year = F$INTEGER(F$EXTRACT(7,4,time)) !Get current year $ IF next_month.EQS."JAN" THEN year = year + 1 $ abs_date = "01-" + next_month + "-" + F$STRING(year) $ GOTO 'subr_return' $!