  DCL Lexicals and Calculating Time? 
 The Question is:
 
Hi,
 
Can someone tell me what the syntax is for submitting a batch job to run weekly
 at 8:00PM?
 
$ submit/nonotify/nodelete/noprint/queue=cals$batch/after="???+20:00"/user=cals
 /name=tkey_check cals$exe:tkey_check.com
 
I'm not sure what to input in the ??? to get it to run once a week at 8:00pm.
 
Many thanks,
 
Phung Tran
716-274-5413
tranp@medevaus.com
 
 
 
 
 The Answer is:
 
  The easiest approach is simply to have the batch job resubmit itself
  each night at 20:00, and simply exit if it is not the correct day.
  A somewhat more involved example follows.
 
  Alternatively, if you want to submit the job seven days and 20 hours
  from the current day (at midnight) the following will work:
 
    f$cvtime("today+7-20:00","absolute")
 
	--
 
$! BCK.COM
$!
$! Copyright 2000 Compaq
$!
$! A procedure that submits itself as a batch job, and is used for
$! backing up a workstation to a (sufficiently large) tape drive...
$! This procedure resets /NOBACKUP status on several directories,
$! and it issues PURGEs.
$!
$! This batch job runs a full backup (with /RECORD) on Friday night,
$! and incrementals the other nights.
$!
$! To submit the batch job, simply invoke this procedure with no
$! options specified.  A batch job will be submitted to SYS$BATCH:.
$!
$! written circa 29-Jan-1997, various updates...
$! Stephen Hoffman
$! Compaq OpenVMS Engineering
$!
$! P1 is a comma-seperated list of options
$!	F: do FULL tonight (override default)
$!	N: do it NOW, and not /AFTER=TOMORROW+23:00
 
$ Set NoOn
 
$ mynameis = f$environment("PROCEDURE")
$ mynameis = mynameis - f$parse(mynameis,,,"VERSION")
 
$ goto 'f$mode()'
 
$INTERACTIVE:
$NETWORK:
$OTHER:
 
$! see if we should do this now, else wait...
 
$ NOW = "FALSE"
$ if f$locate(",N,",",''p1',") .ne. f$length(",''p1',") then NOW = "TRUE"
 
$ If (NOW)
$ Then
$   After = ""
$ Else
$   After = "/AFTER=""TOMORROW+23:00"" "
$ EndIf
 
$ SUBMIT 'mynameis' 'After' -
	/NOPRINT/KEEP/PARAM=("''p1'") -
	/LOG_File=SRH:[BCK]BCK.LOG/NAME=BACKUP
 
$ Exit
 
$BATCH:
 
$ Set Process/Prio=2
 
$ SET VERIFY
 
$ SUBMIT 'mynameis' -
	/AFTER="TOMORROW+23:00"/NOPRINT/KEEP -
	/LOG_File=SRH:[BCK]BCK.LOG/NAME=BACKUP
$ PURGE SYS$LOGIN:BCK.LOG/KEEP=14
 
$ purg SYS$SYSROOT:[SYSCOMMON.AMDS]*.log/log
$ set file SYS$SYSROOT:[SYSCOMMON.AMDS]*.log;*/noback
$ set file SYS$SYSROOT:[SYSCOMMON.DECW$BOOK]*.*;*/noback
$ set file SRH:[SCRATCH...]*.*;*/noback
 
$ day = F$Edit(f$cvtim(,,"WEEKDAY"),"COLLAPSE,UPCASE")
 
$! see if a full backup should be performed, default not...
 
$ DOFULL = "FALSE"
$ if "''day'" .eqs. "FRIDAY" then DOFULL = "TRUE"
$ if f$locate(",F,",",''p1',") .ne. f$length(",''p1',") then DOFULL = "TRUE"
 
$ if (DOFULL)
$ Then
$    Call FULL
$ Else
$    Call INCR
$ EndIf
 
$ if "''day'" .eqs. "THURSDAY"
$ Then
$    DISMOUNT/UNLOAD MKA500:
$    Reply/All/Bell "Unloading tape -- please load tape for Friday"
$ Else
$    DISMOUNT/NOUNLOAD MKA500:
$ EndIf
 
 
$ Exit
 
$INCR: SUBROUTINE
$ Set NoOn
$ Reply/All/Bell "Starting Incremental Backup"
$ Write sys$output "Starting Incremental Backup"
$ Mount/Foreign/NoAssist/MEDIA_FORMAT=COMPACTION MKA500:
$ saveset = f$cvtime(,"COMPARISON","DATE") + ".BCK" - "-" - "-"
$ comment = "Incremental " + f$cvtime(,,"DATE")
$ Backup -
	Sys$SysDevice:[*...]*.*;*/SINCE=BACKUP -
	MKA500:'saveset'/Save/NoRewi -
	/Comment="''comment'" -
	/Label=BCK/Igno=(Label)/Verif
$ if $severity .and. 1
$ then
$   write sys$output "Incremental BACKUP completed"
$   Reply/All/Bell "Incremental BACKUP completed"
$ else
$   write sys$output "Incremental Backup completed with error(s)"
$   Reply/All/Bell "Incremental Backup completed with error(s)"
$ endif
$ Return
$ EndSubroutine
 
$FULL: SUBROUTINE
$ Set NoOn
$ Reply/All/Bell "Starting Full Backup"
$ Write sys$output "Starting Full Backup"
$ INITIALIZE/MEDIA_FORMAT=COMPACTION MKA500:
$ Mount/For/NoAssist/MEDIA_FORMAT=COMPACTION MKA500:
$ saveset = f$cvtime(,"COMPARISON","DATE") + ".BCK" - "-" - "-"
$ comment = "Full " + f$cvtime(,,"DATE")
$ Backup -
	Sys$SysDevice:/Image -
	MKA500:'saveset'/Save/Rewi -
	/Comment="''comment'" -
	/Label=BCK/Igno=(Label)/Verif/Record
$ if $severity .and. 1
$ then
$   write sys$output "Full BACKUP completed"
$   Reply/All/Bell "Full BACKUP completed"
$ else
$   write sys$output "Full Backup completed with error(s)"
$   Reply/All/Bell "Full Backup completed with error(s)"
$ endif
$ Return
$ EndSubroutine
