$!.. EVERYMNTH.JOB Monthly batch job control procedure $ SET NOON $ every_queue = "SHORT_JOBS" !Queue for system's EVERY* jobs $ SUBMIT_JOB := SUBMIT /QUEUE='every_queue' /PRIORITY=28 /NOPRINT - /LOG_FILE=CMN$MANAGER: /USER=SYSMANAGER /NAME=EVERYMNTH $ IF P1 .EQS. "ONCEONLY" THEN GOTO DO_MY_THING !Once-only submission $ IF P1 .NES. "GOGOGO" THEN GOTO FIRST_TIME_THRU !Setup submission $ SET PROCESS/PRIORITY=12 !Raise process's priority $ PURGE EVERYMNTH.LOG !Purge old versions of log file $ subr_return := NORMAL_RESUBMIT !Set subroutine call return point $ GOTO CALCULATE_DATE !Get date of 1st of next month $NORMAL_RESUBMIT: $! Re-submit to run at midnight on the first day of the next month. $ SUBMIT_JOB /AFTER='abs_date' - SYS$MGR_UTIL:EVERYMNTH.JOB /PARAMETERS=GOGOGO $DO_MY_THING: $@SYS$MGR_UTIL:EVERYMNTH.COM !Here is where the real work gets done $ EXIT ! End-of-job for this month $FIRST_TIME_THRU: !First time: @EVERYMNTH.JOB [IFF_]SETUP $ IF p1 .EQS. "SETUP" THEN $ GOTO UNCONDITIONAL_RESTART $ ON WARNING THEN $ GOTO NONE_IN_QUEUE !If no jobs found in queue scan... $@FERMI$UTIL:BATJOBTST EVERYMNTH 'every_queue' SYSMANAGER $ EXIT !Job already queued, just exit! $UNCONDITIONAL_RESTART: !First time: @EVERYMNTH.JOB SETUP $@FERMI$UTIL:BATQUEDEL EVERYMNTH 'every_queue' SYSMANAGER $ IF job_time .EQS. "" THEN GOTO NONE_IN_QUEUE $! Deleted one pending, resubmit with the absolute time from deleted job. $ SUBMIT_JOB /AFTER='job_time' - SYS$MGR_UTIL:EVERYMNTH.JOB /PARAMETERS=GOGOGO $ EXIT $NONE_IN_QUEUE: !No jobs were queued $ subr_return := NONE_IN_QUEUE_1 !Set subroutine call return point $ GOTO CALCULATE_DATE !Get date of 1st of next month $NONE_IN_QUEUE_1: $ SUBMIT_JOB /AFTER='abs_date' - SYS$MGR_UTIL:EVERYMNTH.JOB /PARAMETERS=GOGOGO $ EXIT $!============================================================================= $CALCULATE_DATE: !Calculate absolute date of 1st of next month in ABS_TIME $ time = F$TIME() $ this_month = F$EDIT( F$CVTIME(time, "ABSOLUTE", "MONTH"), "UPCASE") !Cur. mo. $ months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDECJAN" $ where = F$LOCATE( this_month, months) + 3 $ next_month = F$EXTRACT( where,3, months) !Name of next month $ year = F$INTEGER( F$CVTIME( time, "ABSOLUTE", "YEAR")) !Get current year $ IF next_month .EQS. "JAN" THEN year = year + 1 !Bump year if now DEC $ abs_date = "01-" + next_month + "-" + F$STRING(year) $ GOTO 'subr_return' !Return ABS_DATE as "01-mmm-yyyy" for next month $!============================================================================== $! EVERYMNTH.JOB $!+ 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 $! $!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 EVERYMNTH batch job (also deletes any such $! jobs currently in the batch queue). Does not execute $! EVERYMNTH.COM. This is an unconditional restart. $! $! IFF_SETUP same as SETUP if, and only if, there is not an EVERYMNTH $! job already in the queue (conditional restart). $! $! 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. $!- $!============================================================================= $! Author: 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 $! 29-Nov-83 FJN Moved BATQUEDEL to FERMI$UTIL $! 29-Aug-84 LAV Removed show queue commands (after submit batch job) $! 05-Sep-84 FJN Finally changed job name to EVERYMTNH! $! 26-Oct-84 FJN Run EVERYMNTH job from SHORT_JOBS queue $! 07-Jun-85 FJN Make use of VMS V4 lexical functions and other features $! and compress/move comments $! 09-Jun-85 FJN Add IFF_SETUP to restart job if-and-only-if there is $! no EVERYMNTH job already queued $! 17-Oct-85 FJN Correct future date calculation under VMS V4 $! 18-Oct-85 FJN Put EVERYMNTH.LOG file into CMN$MANAGER