Operating System - OpenVMS
1748180 Members
4040 Online
108759 Solutions
New Discussion юеВ

Re: Submiting a batch job to run automatically twice a year

 
SOLVED
Go to solution
Steve ward_3
Advisor

Submiting a batch job to run automatically twice a year

How can I set up a batch job to run every quarter automatically.

Ex. April 30th, August 31st and December 31st

34 REPLIES 34
labadie_1
Honored Contributor
Solution

Re: Submiting a batch job to run automatically twice a year

For example the following

$ MONTHS = "//FEB/MAR/APR/MAY/JUN/JUL/AUG/SEP/OCT/NOV/DEC/JAN"
$ YEAR = 'F$CVT(,,"YEAR")
$ MONTH= 'F$CVT(,,"MONTH")'
$ IF MONTH .EQ. 12 THEN YEAR = YEAR + 1
$ MONTH = F$ELEMENT(MONTH+3, "/", MONTHS)
$ SUBMIT/AFTER=1-'MONTH'-'YEAR' 'f$env("procedure")

submits for the first day every 3 months.

I search for a trick to find the last day of month easily, but I guess others will have posted in the meantime...
Steven Schweda
Honored Contributor

Re: Submiting a batch job to run automatically twice a year

You can also have it resubmit itself every
day, but only _do_ something on particular
days.

> [...] automatically twice a year

> [...] every quarter [...]

Around here, "every quarter" would involve
more than "twice a year". (And perhaps once
between April and August.)
labadie_1
Honored Contributor

Re: Submiting a batch job to run automatically twice a year

$ Temp = F$CVTIME(,"ABSOLUTE")
$ Temp = F$CVTIME("01"+(Temp-F$ELEMENT(0,"-",Temp))+"+125-","ABSOLUTE")
$ Last3 = F$CVTIME("01"+(Temp-F$ELEMENT(0,"-",Temp))+"-1-",-
"ABSOLUTE","DATE")
$ submit /after='last3 'f$env("procedure")
Steve ward_3
Advisor

Re: Submiting a batch job to run automatically twice a year

How about if I want to submit it on a certain day Ex. On every 2nd week on Friday for april august and december?

Shankar Bose
Advisor

Re: Submiting a batch job to run automatically twice a year

Use a data file to store the names of months you want to run the job. Have the job resubmit itself everyday, but only _do_ something on all the three condition getting satisfied. For 2nd week of a month the days must be between 8 to 14 and run the job if it is Friday of a month mentioned in the data file
Jan van den Ende
Honored Contributor

Re: Submiting a batch job to run automatically twice a year

Steve,

In 2004 I posted this to dcl.openvms.org:

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

A procedure that lets you specify all kinds of variables for calculating next submit.

eg: Last sunday of every month, or (your latest question) first Friday after 8th of month where month # a certain multiple.

This procedure contains a fairly extended "manual" in its comments.

hth

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Shankar Bose
Advisor

Re: Submiting a batch job to run automatically twice a year

Instead of data file you can keep the months name in a variable also. It is easier that way.
Robert Gezelter
Honored Contributor

Re: Submiting a batch job to run automatically twice a year

Steve,

April, August, and December is three times a year, neither two nor four!

That said, the approach of adding to the current month will work. You can use the F$CVTIME lexical function within the DCL procedure to extract the current month from the current time (which can be obtained using F$TIME).

The "second Friday" part is trickier. If I were doing the computation, I would likely get the weekday (also available using F$CVTIME) for the 1st of the month and then compute the adjustment, or I could compute the day of the week for the 13th (the earliest date within a month that can be the second Friday), and adjust accordingly.

Note that F$CVTIME when used in "COMPARISON" mode returns numeric values, which are easier to process in this situation.

One should also take care in the event that the procedure is run at some other time that the calculations do not misfire.

- Bob Gezelter, http://www.rlgsc.com
Jan van den Ende
Honored Contributor

Re: Submiting a batch job to run automatically twice a year

@ Bob:

>>>
for the 13th (the earliest date within a month that can be the second Friday),
<<<

In MY book, when the 1st of any month is a Friday, that month the 8th is counted as the second Friday... :-)


Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.