Operating System - OpenVMS
cancel
Showing results for
Did you mean:

SOLVED
Go to solution

## 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
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...
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.)
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")

## 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?

## 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
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.

## 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.
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
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.
Honored Contributor

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

If you do not have to submit too often, may be a simple solution is to put the dates in the dcl
and from time to time update the command file.

You do not need to resubmit it, just do, if your command file is a.com, after modfying it
from a.com;1 to a.com;2

\$ copy/overlay a.com;2 a.com;1

and the "new" a.com will be used for the next submit.
Honored Contributor

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

Jan,

Indeed, I mis-spoke[sic].

The second Friday of the month ranges from the 9th (when the month starts on a Thursday), to the 15th (when the month starts on a Friday).

(smile) Obviously, one needs to exercise caution when dealing with the fourth and fifth weeks of the month.

- Bob Gezelter, http://www.rlgsc.com
Honored Contributor

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

To all,

My apologies, this does not seem to be my day for calendars.

The lowest day of month for the "second Friday" is the 8th (if the month starts on the previous Friday). The highest day of month is the 14th (if the month started on a Saturday).

My apologies for the errata.

- Bob Gezelter, http://www.rlgsc.com
Honored Contributor

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

Steve,

The "trick" to get the last day of the month is to use "one day before the start of the next month", to wit:

\$ LASTDATE = F\$CVTIME("1-MAR-2008-1-0",,"DATE)

Yields 29-Feb-2008. Note that this automatically deals with leap years.

- Bob Gezelter, http://www.rlgsc.com
Honored Contributor

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

There are numerous potential problems with having jobs submitted into the "distant" future (more than say, 1 month).

As others have suggested, I find you're much better off having the job execute frequently (daily is easiest) and checking on each run if there's anything to be done.

A few tricks to make coding easier and clearer...

For a job that should do something each week day:

\$ SUBMIT self for tomorrow
\$ GOTO 'F\$CVTIME(,,"WEEKDAY")
\$
\$ Saturday:
\$ Sunday:
\$ EXIT
\$
\$ Monday:
\$ Tuesday:
\$ Wednesday:
\$ Thursday:
\$ Friday:
\$ ! Do work here

Obvious modifications for doing different things on specific weekdays.

For first of the month:

\$ IF F\$CVTIME(,,"DAY").EQS."01"
\$ THEN
\$ ! Today is first of month
\$ ENDIF

For last day of month

\$ IF F\$CVTIME(,,"MONTH").NES.F\$CVTIME("+1-",,"MONTH")
\$ THEN
\$ ! Today is last day of month
\$ ENDIF

For a calendar of arbitrary dates, store them in a file:

\$ PIPE SEARCH ACTION_DATES.DAT "''F\$CVTIME(,"ABSOLUTE","DATE")'" >nl: 2>nl:
\$ IF \$SEVERITY.EQS."1"
\$ THEN
\$ ! today is listed in ACTION_DATES.DAT
\$ ENDIF
A crucible of informative mistakes

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

Can someone just give me a simple if then else command to achieve what I am looking for.

I want to be able to execute a job that will check for a certain date and if it is that date to submit it automatically.

Let's say i want this job to run on the 2nd week on a particular day {tuesday) in June and then again in Decemember?

Is there a simple DCL command to do this, without making it too complicated!

Ex.

Maybe something that says

if today is the 14th of june or Decemeber and the day is tuesday then submit this job?

Something to that effect?

Just want somethinmg simple if at all possible.

Thanks!
Honored Contributor

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

> Can someone just give me a simple [...]

Perhaps, but I doubt it.

> [...] check for a certain date [...]

I think that that's been provided already.

> Let's say i want this job to run on the 2nd
> week on a particular day {tuesday) [...]

No problem. Define "2nd week".

> Just want somethinmg simple if at all
> possible.

A clear, unambiguous description of the
problem can be a big help. I haven't seen
one yet. Some thought may be required. Get
used to it. If you can't specify the problem
clearly enough for someone else to do your
job for you, then you may need to do some
playing around with the suggestions you get,
to see if you can adapt the concepts to
whatever it is that you actually want to do.

Am I being too grumpy again?

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

The com file is out there but for some reason it doesn't execute the submit command when it does find it??

Am I missing something?

\$ if (f\$search("steve_ward:'node'_ward.com") .eqs. "")
\$ then
\$ write sys\$output "WARD.COM file missing! Program will NOT run."
\$ goto the_end
\$ else
\$ SUBMIT/NOPRINT/QUE=SYS\$BATCH/LOG=STEVE_WARD:[000000]'node'_WARD.COM
Honored Contributor

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

Steve,

>>>
if (f\$search("steve_ward:'node'_ward.com") .eqs. "")
<<<
Is this an exact copy/paste, or a nearly accurate attempt to re-type?

It SHOULD be (and for clarity I added spaces, which do NOT belong!)
if (f\$search(" steve_ward: ' ' node ' _ward.com") .eqs. "")

Notice: Between double quotes, you need TWO apostrophes to begin synbol substitution, and one to end it.

And why do you f\$search
"steve_ward:'node'_ward.com")
but if you find it, you SUBMIT
>>>
STEVE_WARD:[000000]'node'_WARD.COM
<<<
It will work a lot better of you SUBMIT STEVE_WARD:'node'_WARD.COM

Explanation:
In the search, STEVE_WARD obviously is a logical name for a directory (or you would not find anything)
But in STEVE_WARD:[000000] you specify a DEVICE )potentially a Concealed Device) named STEVE_WARD; which has a top-directory [000000] (for concealed devices that would be the pseudo directory, pointing to the root level itself), where the .COM file should reside.
But, STEVE_WARD can NEVER be simaultabiously both a Device spec AND a Directory-spec.

hth

Proost.

Have one on me.

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

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

Duh

>>>
simaultabiously
<<<

Proost.

Have one on me.

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

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

Okay, here I go again

Why doesn't it submit the job when it find the com file that I am searching for??

It just gives me file is miising, but it isn't!

\$ if (f\$search("home_scr:'node'_snapshot.com") .eqs. "")
\$ then
\$ write sys\$output "SNAPShot.COM file missing! Program will NOT run."
\$ goto the_end
\$ else
\$ SUBMIT/NOPRINT/QUE=sys\$BATCH/LOG=home_LOGS:home_scr:[SCRIPTS]'node'_SNAPSHot.COM
Honored Contributor

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

Steve,

Inside a quoted string (such as in your IF statement), you need two apostrophes to begin symbol substitution.

Therefore you need apostrophe apostrophe node apostrophe.

See the attached text file for details

Duncan

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

Thanks the submit worked when it found that file, but when it doesn't I get a message
%SUBMIT-F-OPENIN, error opening \$1\$DUA1:[ward]Trek_SNAPSHOT.COM; as input

write sys\$output "SNAPSHRINK.COM file missing! Program will NOT run."

So if it does find that file that it is searchig the submit works, but then when I delete that file and reran it, if should come up with the sys\$output message?

Shouldn't it?

Honored Contributor

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

Steve,

>>>
%SUBMIT-F-OPENIN, error opening \$1\$DUA1:[ward]Trek_SNAPSHOT.COM; as input

write sys\$output "SNAPSHRINK.COM file missing! Program will NOT run."
<<<

Now _I_ am getting a little confused.

So, some questions

- WHAT is the exact name of the file you want to submit
- WHERE (device, directory) is that file located
- HOW does STEVE_WARD translate
- WHAT is the value of NODE in the context of this process (add a
\$ SHOW SYMBOL NODE
and
\$ SHOW LOGICAL/FULL STEVE_WARD
as the lines before the f\$SEARCH)

I am beginning to think that I was put on the wrong track (derailed, actually) until now.

Proost.

Have one on me.

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

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

>> I get a message
%SUBMIT-F-OPENIN, error opening \$1\$DUA1:[ward]Trek_SNAPSHOT.COM; as input

write sys\$output "SNAPSHRINK.COM file missing! Program will NOT run."
<<

It looks like you may not be doing any error checking. Since you got an ERROR, processing of the command procedure stopped and exited - so no "write sys\$ouput"