1827892 Members
1961 Online
109969 Solutions
New Discussion

batch queue

 
SOLVED
Go to solution
Taulant Shamo
Frequent Advisor

batch queue

Hello,

I have to create a job to run automatically every first and 15-th day of every month?

For excecuting it every day at 01:00 I have created as below:

submit/AFTER="TOMORROW +1" DSA1:[VODAFONE.TEST]bep1_backup_test.com
12 REPLIES 12
Antoniov.
Honored Contributor
Solution

Re: batch queue

Hi,
if you submit in same month you can simply write:
$! Get today date in forma dd-mmm-yyyy hh:mm
$ MYDATE=F$CVTIME("","ABSOLUTE")
$! Change first 2 chars
$ MYDATE="15"+F$EXTRACT(2,9,MYDATE)
$! Submit command
$ SUBMIT/AFTER='MYDATE' DSA1:[VODAFONE ...

Antonio Vigliotti
Antonio Maria Vigliotti
Mobeen_1
Esteemed Contributor

Re: batch queue

Taulant,
As Antonio has illustrated make use of F$CVTIME() lexical. That will help you.

regards
Mobeen
Daniel Fernandez Illan
Trusted Contributor

Re: batch queue

Hello.
A possible solution is to use an auxiliar command file as (batch.com):

$set noon
$io=f$cvtime("","absolute","day")
$if io .eqs. "1" .or. io .eqs. "15" then -
submit DSA1:[VODAFONE.TEST]bep1_backup_test.com
$submit/after="tomorrow +1" batch.com
$exit

Best Regards.

Willem Grooters
Honored Contributor

Re: batch queue

This works for a two-week schedule:

$ submit/after="tomorrow +14-00:00:00.00" x.com

otherwise, youi may have to calculate the next date to have it run. There are several ways to do this - attachted an example.
Willem Grooters
OpenVMS Developer & System Manager
Ian Miller.
Honored Contributor

Re: batch queue

In addition to the good suggestions so far -
A further point is to ensure you do the re-submitting at the beginning of your batch job incase of problems or delays.
____________________
Purely Personal Opinion
Hein van den Heuvel
Honored Contributor

Re: batch queue


It may be helpful to know that DCL/VMS default all parts of a datespec to the current. So providing "15-" for a date will give the 15th of the current month.
Second, adding 31 days to a date give next month (and next year if needed). Combined this suggests the solution (in test file format):

$if p1.eqs."" then p1 = f$cvtime("","absolute","day")
$if 'p1'.lt.15
$then
$ next = f$cvt("15-","absolute")
$else
$ next = "1-" + f$cvt("+31-","absolute","month") -
+ "-" + f$cvt("+31-","absolute","year")
$endif
$show symb next

Hein.

Willem Grooters
Honored Contributor

Re: batch queue

Ach Hein,

Zoals gezegd: er zijn meerdere wegen die naar Rome leiden, nietwaar? Ik hou alleen niet van die one-liners - ze hebben de neiging nogal obscuur te zijn (en dientengevolge niet te onderhouden).

In English for thos that do not understand Ditch (cannot help Hein is Dutch like me...)
As said: there are more road leading to Rome. I just don't like one-liners - they tend to be rather obscure (and hance unmaintainable)

Willem
Willem Grooters
OpenVMS Developer & System Manager
John Gillings
Honored Contributor

Re: batch queue

I think there's a couple of bugs in Hein's code (consider 31st Jan?).

Finding the 1st and 15th of this month is easy:

$ first=F$CVTIME("1-","ABSOLUTE")
$ fifteenth=F$CVTIME("15-","ABSOLUTE")

To work out the 1st and 15th of next month regardless of the current date:

$! find a date in next month
$ next=F$CVTIME("1-+31-","ABSOLUTE")
$ nextmonth=-
F$CVTIME(next,"ABSOLUTE","MONTH")+-
"-"+F$CVTIME(next,,"YEAR")
$ first="1-"+nextmonth
$ fifteenth="15-"+nextmonth

The compound time "1-+31-" breaks into two parts, "1-" means "first of this month", then "+31-" means add 31 days. This will always be a date in the following month.
(Hopefully this isn't too obscure for Willem?)

Slight variation and generalisation- to find the next "Nth of the month", you need to consider the current date:

$ N=15
$ IF F$CVTIME(,,"DAY").LT.N
$ THEN ! Nth of this month
$ nth=F$CVTIME("''N'-","ABSOLUTE")
$ ELSE ! Nth of next month
$ ! above code reduced to 1 liner
$ nth="''N'-"+-
F$CVTIME("1-+31-","ABSOLUTE","MONTH")+-
"-"+F$CVTIME("1-+31-",,"YEAR")
$ ENDIF

To have a job that runs on 1st and 15th, you could either code up logic that alternates between 1st and 15th, or you could have two periodic jobs, one resubmitting itself for 1st and the other for the 15th, calling the same procedure to do the actual work. For example:

NTH_OF_MONTH.COM
$!
$! P1=day in month to execute job (D=1st)
$! P2=procedure to execute (required)
$! P3=extra SUBMIT qualifiers (optional)
$!
$ N=p1
$ IF N.EQS."" THEN N=1
$ IF F$CVTIME(,,"DAY").LT.N
$ THEN ! Nth of this month
$ nth=F$CVTIME("''N'-","ABSOLUTE")
$ ELSE ! Nth of next month
$ nth="''N'-"+-
F$CVTIME("1-+31-","ABSOLUTE","MONTH")+-
"-"+F$CVTIME("1-+31-",,"YEAR")
$ ENDIF
$
$ SUBMIT/AFTER="''nth'" 'p3' -
'F$ENVIRONMENT("PROCEDURE") -
/PARAM=("''p1'","''p2'","''p3'","DOIT")
$ IF p4.EQS."DOIT" THEN @'p2'
$ EXIT


$ @NTH_OF_MONTH 1 MYJOB.COM "/QUEUE=MYQUEUE"
$ @NTH_OF_MONTH 15 MYJOB.COM

This easily generalises to any monthly schedule you like.
A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: batch queue

Ok... so add 16 or 20, just not 31.
(Since you are only adding after the 15th)

I was just testing you guys...

:-)

Hein.
Jan van den Ende
Honored Contributor

Re: batch queue

Hi all!

For several years now we have a general purpose routine GET_NEXT_DATUM which does this.
(and more: also gives answers like LAST WEDNESDAY (of month) or LAST MONDAY before n-th of the month).
Calculations are leapyear aware.
To make it useful to a wider public I translated the instructions and messages into English, and posted it to DCL.OPENVMS.ORG
When it will be published there, I post the URL as well.

Hth

Cheers.

Have one on me.


Jan
Don't rust yours pelled jacker to fine doll missed aches.
Jan van den Ende
Honored Contributor

Re: batch queue

Okay,

the procedure is at
http://dcl.openvms.org/stories.php?story=04/10/15/8590853

Usage: eg

@:get_next_datum LAST wednesday
or
@:get_next_datum 12 sunday

the first one should be clear.

The second one returns 6, 7, ... 11, or 12;
whichever is sunday,
of THIS month if that is tomorrow or later, else of next month.

And then eg.
$ submit /after="''next_datum'+1:23"
will mean at the specified day at 1:23.

Until now _WE_ have not found it to be lacking. YMMV

Cheers

Have one on me

Jan



Don't rust yours pelled jacker to fine doll missed aches.
Taulant Shamo
Frequent Advisor

Re: batch queue

Thank you all