Operating System - OpenVMS
1827987 Members
2314 Online
109973 Solutions
New Discussion

Re: Running a VMS batch job three times a day

 
SOLVED
Go to solution
Sk Noorul  Hassan
Regular Advisor

Running a VMS batch job three times a day

I want to execute a DCL script using a batch job three times a day. Can anybody suggest the timings definition inside the job, so that it runs three times a day(09:30, 16:30 & 23:30) and after that it should submit for tommorrow ?
4 REPLIES 4
Bradford Hamilton
Regular Advisor

Re: Running a VMS batch job three times a day

Here's some code for twice-a-day resubmission - modify as needed (apologies for the "messy" line-wrapping):

! BRAD_ONCALL.COM - Schedule to change value of ONCALL for WATCHDOG
! notifications.
! BJH/JNZ - 07-AUG-2003
!
$!
$ weekday=f$cvtime("today",,"Weekday")
$ time=f$cvtime("","absolute","time")
$!
$ if time .gts. "00:00:00.00" .and. time .lts. "07:00:00.00"
$ then
$ define/sys oncall "@sys$manager:notify_brad.dis"
$ define/table=rampage$logicals oncall "@sys$rampage:notify_brad.dis"
$ submit/nolog/restart/after=07:00 brad_oncall.com
$ exit
$!
$ else
$ if time .gts. "07:00:00.00" .and. time .lts. "17:00:00.00"
$ then
$ define/sys oncall "@sys$manager:notify_day.dis"
$ define/table=rampage$logicals oncall "@sys$rampage:notify_day.dis"
$ submit/nolog/restart/after=17:00 brad_oncall.com
$ exit
$!
$ else
$ if weekday .eqs. "Friday"
$ then
$ submit/nolog/restart/after="tod+3-07:00" brad_oncall.com
$ define/sys oncall "@sys$manager:notify_brad.dis"
$ define/table=rampage$logicals oncall "@sys$rampage:notify_brad.dis"
$ else
$ if weekday .eqs. "Monday"
$ then
$ submit/nolog/restart/after="tod+8-07:00" brad_oncall.com
$ define/sys oncall "@sys$manager:notify_brad.dis"
$ define/table=rampage$logicals oncall "@sys$rampage:notify_brad.dis"
$ else
$ submit/nolog/restart/after="tod+1-07:00" brad_oncall.com
$ define/sys oncall "@sys$manager:notify_brad.dis"
$ define/table=rampage$logicals oncall "@sys$rampage:notify_brad.dis"
$ endif
$!
$ endif
$!
$ endif
$!
$ exit
Joseph Huber_1
Honored Contributor
Solution

Re: Running a VMS batch job three times a day


Your specific case can be done shortly:

$ time=f$cvtime("","absolute","time")
$ after=""
$ if time.lts."23:30:00.00" then after="TODAY+23:30"
$ if time.lts."16:30:00.00" then after="TODAY+16:30"
$ if time.lts."09:30:00.00" then after="TODAY+09:30"
$ if after.eqs."" then after="TOMORROW+09:30"
$ submit/after="''after'" thisfile

The 3rd time comparison can be omitted if You submit the job at 9:30 the first time.

For general scheduling without rewriting every single command-file, look for "cron" implementations for VMS earlier in this forum.
http://www.mpp.mpg.de/~huber
Hans Adriaanse
Advisor

Re: Running a VMS batch job three times a day

Perhaps a little bit more generic:

$!
$! Submit myself again for the next time
$!
$ CALL SUBMITJOB "09:30,16:30,22:30" MYJOBNAME THISJOB.COM SYS$BATCH
$!
$!
$! Do your stuff
$!
$ EXIT
$!
$!============================================================
$ SUBMITJOB:
$ SUBROUTINE
$! Subroutine te reschedule the job at the next time in the schedule.
$! The schedule is given in P1 as a comma seperated list of times
$!
$ COUNT = 0
$! Look for the next time in P1 after the current time.
$ PARAMLOOP:
$ P1 = F$EDIT(P1,"COLLAPSE")
$ NEXT_TIME = F$ELEMENT(COUNT, ",", P1)
$ IF NEXT_TIME .EQS. "," THEN GOTO NEXT_DAY
$ NEXT_TIME_COMP = F$CVTIME(NEXT_TIME)
$ NOW = F$CVTIME()
$ IF NEXT_TIME_COMP .LES. NOW
$ THEN
$ COUNT = COUNT + 1
$ GOTO PARAMLOOP
$ ENDIF
$ GOTO SUBMIT_IT
$!
$ NEXT_DAY:
$! Last time in P1, so another day has gone. So use first time next day.
$ NEXT_TIME = "TOMORROW + ''F$ELEMENT(0,",",P1)'"
$!
$ SUBMIT_IT:
$ SUBMIT/NOTIFY/NOPRINT/RESTART/LOG=CRIS$LOG:'P2'.LOG -
/AFTER="''F$CVTIME(NEXT_TIME, "ABSOLUTE")'" -
/QUEUE='P4' -
'P3'
$ EXIT
$ ENDSUBROUTINE


Have fun,
Hans
Sk Noorul  Hassan
Regular Advisor

Re: Running a VMS batch job three times a day

Thanks guys. I have done it.