Operating System - OpenVMS
1829963 Members
2608 Online
109998 Solutions
New Discussion

Re: submiting a job based on the day of the week

 
patricia_28
New Member

submiting a job based on the day of the week

I a newie to VMS and i am having a problem
using the submit/after command. I need to be able to submit a job every 30 mins, between the hours of 5:00am and midnight, Monday thru Friday and on the weekend (Sat & Sun) between the hrs of 7:00am and midnight. I tried both absolute and delta times with little success.

Any assistance would be greatly apprciated.
Thanks,
Pat
17 REPLIES 17
Robert_Boyd
Respected Contributor

Re: submiting a job based on the day of the week

Pat,

I'm curious about what you tried that didn't work. Of course there is no builtin mechanism in the VMS batch queue syntax to issue a small number of commands to create the behavior that you're looking for.

There are commercial and freeware packages that might make it easier to do something like that.

The most direct method is to create a command procedure that does something like this:

Wake up
Is it between 5:00 AM and Midnight M-F? or between 7AM and midnight on Sat-Sun? if so submit the job to be run
Generate the next time to wake up
(the WAIT command will accept an absolute time so that you can cause the wakeup to occur right on the hour and 30 minute intervals). If the time is after midnight, calculate the next wakeup time as 5:00 AM or 7:00 AM depending on the day of the week.
Wait until next time to wake up

The simplest way of doing this is in a DCL command procedure. There are ways to do the same thing in an executable image of course with fancier bells and whistles, but the DCL solution is pretty straightforward.

Robert
Master you were right about 1 thing -- the negotiations were SHORT!
patricia_28
New Member

Re: submiting a job based on the day of the week

Robert,

Thanks for your response. I'm in the processing of creating a DCL command procedure. I'll let you know how it goes.
Andy Bustamante
Honored Contributor

Re: submiting a job based on the day of the week

See $ help lexical or review the DCL Dictionary at http://h71000.www7.hp.com/doc/732FINAL/9996/9996PRO.HTML

You do exactly what you need with DCL. Depending on your log requirements, another option might be to have 1 job running all day and pausing until the next 30 minute window. Some DCL fragments which might help.


$ DAY_OF_WEEK_NAME = F$CVTIME(,,"WEEKDAY")
.
$ if DAY_OF_WEEK_NAME .eqs. "Sunday" then goto resubmitit
.
$ XHOUR = F$INTEGER(F$EXTRACT(12,2,F$TIME()))
$ if xhour .lt. 2 then . . . .
.
.
$resubmitit:

If the system is booted you'll need something in the startup or use "/restart" in your submit command.
If you don't have time to do it right, when will you have time to do it over? Reach me at first_name + "." + last_name at sysmanager net
Hein van den Heuvel
Honored Contributor

Re: submiting a job based on the day of the week


I like Roberts suggestion a lot. Instead of a complicated re-submit logic, just have the job resubmit in 30 minutes all the time (/after="+0:30")

Then just test for the right window using f$cvtime. Weekend are easy to recognize in english (and dutch) as both days start with the same unique char: S (or Z).


$ weekend = ("S".eqs.f$extr(0,1,f$cvtime(,,"WEEKDAY")))

$start_hour = 5 + 2 * weekend

or

$start_hour = 5 + 2*("S".eqs.f$extr(0,1,f$cvtime(,,"WEEKDAY")))

the full code:

$submi/after="+0:30" 'f$env("procedure")
$if f$cvtime(,,"HOUR").LT. start_hour then exit


A possible selective submit solution (untested):

$next=f$cvtime(" +0:30","ABSOLUTE")
$start_time = "05:00:00"
$ if "S".eqs.f$extr(0,1,f$cvtime(,,"WEEKDAY")) then start_time = "07:00:00"
$ next_time = f$cvtime(next,,"TIME")
$ next_date = f$cvtime(next,"ABSOLUTE","DATE")
$ if next_time.les.start_hour then next_time = start_hour
$ subm/after="''next_date' ''next_time'" 'f$env("procedure")


Enjoy!
Hein.









Hein van den Heuvel
Honored Contributor

Re: submiting a job based on the day of the week


ooops. at least one typo.

$ if "S".eqs.f$extr(0,1,f$cvtime(,,"WEEKDAY")) then start_time = "07:00:00"

That should be:

$ if "S".eqs.f$extr(0,1,f$cvtime(next,,"WEEKDAY")) then start_time = "07:00:00"

Hein.
patricia_28
New Member

Re: submiting a job based on the day of the week

I am not sure who this reply is going to, so I just say thank you to Andy and Hein.

I'll try your suggestions tomorrow and let you know If I was successful.

Thanks again.

Sincerely,
Pat
Robert Gezelter
Honored Contributor

Re: submiting a job based on the day of the week

Pat,

Just a (humerous) follow on to Hein's comment (no offense intended to Hein). I strongly recommend that you check for the entire "day of week" value against a string containing all of the days of the week (e.g., "/Monday/Tuesday/Wednesday/.../Sunday/") using the F$LOCATE lexical function.

If, through some strangeness (or future change in either OpenVMS or the user's configuration), you end up getting the names back in some unexpected language, you will not run "off the rails" in an uncontrolled fashion. I would not rely on the fact that (in English) the names for the weekend days (and only the weekend days) start with "S").

The one extra line of DCL code, and the assocaited check that the name is one of the expected ones, costs little and prevents problems in the future.

- Bob Gezelter, http://www.rlgsc.com
Hein van den Heuvel
Honored Contributor

Re: submiting a job based on the day of the week

>> Just a (humerous) follow on to Hein's comment (no offense intended to Hein). I strongly recommend that you check for the entire "day of week" value against a string containing all of the days of the week (e.g., "/Monday/Tuesday/Wednesday/.../Sunday/") using the F$LOCATE lexical function.

And in that same spirit Bob, how would the French Sunday 'Dimanche' look up in your table Bob?
:-) :-) :-)

Over engineering: If dcl had a day-of-the-I suppose you could determine the day of the week for today, add the appropriate days to make it weekend ask for the name of that day and so on. But then, what is a weekend?
Nah, I'm afraid you'r stuck with hardcoding, and in that case "S" is hust about as bad as "Saturday". Admittedly, with "Saturday" you could do the belt and suspenders thing of reporting an error if the day is not found in the table at all.

More readable, still language dependend, solution:

$ weekend = " Saturday Sunday "
$ start_hour = 5 + 2*(f$len(weekend).ne.f$loc(f$cvtime(,,"WEEKDAY"),weekend))

Cheers,
Hein.


Robert_Boyd
Respected Contributor

Re: submiting a job based on the day of the week

$! DAYOFWEEK.COM -- EXECUTE DAYOFWEEK PROGRAM AND PRINT IT TO SYS$OUTPUT
$! P1 -- global symbol to put the value into
$! P2 -- ,, ,, ,, ,, ,, day name into
$! p3 -- time to use
$ vfl = F$VERIFY(0)
$ sunday = 0
$ monday = 1
$ tuesday = 2
$ wednesday = 3
$ thursday = 4
$ friday = 5
$ saturday = 6
$ day_name = f$cvtime(p3,,"weekday")
$ day_num = 'day_name'
$ IF P1 .NES. "" THEN GOTO ret_parm
$ WRITE SYS$OUTPUT "Today is ",day_name,"."
$ EXIT
$ ret_parm:
$ 'P1' == day_num
$ IF P2 .NES. "" THEN 'P2' == day_name
$ vfl = F$VERIFY(vfl)
$ EXIT
$!Last Modified: 16-OCT-1987 09:38:21.12, By: RLB
Master you were right about 1 thing -- the negotiations were SHORT!
John Gillings
Honored Contributor

Re: submiting a job based on the day of the week

re: selection control structure depending on weekday...

For slightly more language independence give the work to DCL. You can code for several languages (but *complete* language independence might be a bit voluminous) like this:

$ ON WARNING THEN GOTO UnexpectedDay
$ GOTO DAY_'F$CVTIME(,,"WEEKDAY")
$ UnexpectedDay:
$ ! Error Trap
$ EXIT
$ ...
$ DAY_Sunday:
$ DAY_Saturday:
$ DAY_Dimanche:
$ DAY_weekend-in-your-language:
$ ! Weekend branch
$ GOTO BackToMainLine
$
$ DAY_Monday:
$ DAY_Tuesday:
$ DAY_Wednesday:
$ etc...
$ ! Weekday branch
$ GOTO BackToMainLine

If you're running V8.2 or higher, there are more options. Specifically we can eliminate all language dependencies.

1-JAN-1990 was a Monday, so:

$ J=F$DELTA("1-JAN-1990",F$TIME())
$ D=J-J/7*7

will return 0 for Monday, 1 for Tuesday etc... So your test for a weekend day becomes simply:

$ IF D.GE.5
$ THEN
$ ! weekend branch
$ ELSE
$ ! weekday branch
$ ENDIF

WARNING - since Delta times are limited to 10000 days, the above code will fail for dates after May 2017.

I think I'll a suggestion that F$CVTIME(date,"COMPARISON","WEEKDAY") should return a number...
A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: submiting a job based on the day of the week

>> 1-JAN-1990 was a Monday, so:
>>
>> $ J=F$DELTA("1-JAN-1990",F$TIME())
>> $ D=J-J/7*7

Ah... My kinda thinking, but I did not have V8 to try. Good.


>> the above code will fail for dates after May 2017.

or you could just start closer in.


>> I think I'll a suggestion that F$CVTIME(date,"COMPARISON","WEEKDAY") should return a number...

I suppose you could call it a a low impact bug, as "MONTH" already does the right thing for ABS vs COMPARE


Cheers,
Hein.
John Gillings
Honored Contributor

Re: submiting a job based on the day of the week

Hein,

>I suppose you could call it a a low impact bug, as "MONTH" already does the right thing for ABS vs COMPARE

Unfortunately it's not quite as simple as it seems at first. The default output format is "COMPARISON", so to do this in a safe, upwards compatible manner, we'd have to change the default output format for "WEEKDAY" to "ABSOLUTE" and return numeric values only if the output format was explicitly "COMPARISON". It's probably more difficult to describe in the documentation than actually implement...
A crucible of informative mistakes
patricia_28
New Member

Re: submiting a job based on the day of the week

Hi to All,
Sorry I didn't reply sooner. Thank you for all your responses. I "TRULY" appreciate the help. I won't be able to work on this issue until Monday. Bosses are always changing priorities. I will keep you posted on my progress. Thanks again.

Sincerely,
Pat
Robert Gezelter
Honored Contributor

Re: submiting a job based on the day of the week

Hein,

(Smile) Perhaps I was unclear, I did write that response in a hurry.

I meant to say:
- If you find "Saturday" or "Sunday", then you are ok.
- If no string matches, take some appropriate action (error message: "Language not English"... If I had the time, I would delve into the multi-language support, my recollection is that there is a clean way to tell if your language is English, but it should not be too hard to find in the manual.

- Bob Gezelter, http://www.rlgsc.com
Doug Graver
Occasional Advisor

Re: submiting a job based on the day of the week

$ show logical sys$language

(LNM$SYSTEM_TABLE)

"SYS$LANGUAGE" = "ENGLISH"

Lawrence Czlapinski
Trusted Contributor

Re: submiting a job based on the day of the week

It would be nice if VMS had a logical for weekend, weekend_day_1 and weekend_day_2 since system managers often have to create DCL which checks for weekend, Saturday, or Sunday.
A freeware international solution of the day of week might include something like this using symbols:
$! Is_Weekend.com
$! Defines weekend names.
$weekend==""
$weekend_day_1=""
$weekend_day_2=""
$if (f$trnlnm("SYS$LANGUAGE")) .eqs. "ENGLISH"
$THEN
$ weekend_table=="Saturday,Sunday"
$ weekend_day_1=="Saturday"
$ weekend_day_2=="Sunday"
$ELSE
$! Non-English Customizations
$ENDIF
.
.
.
$exit

or it could be done with system logicals.

Robert_Boyd
Respected Contributor

Re: submiting a job based on the day of the week

You don't have to wait for V8.2 to take advantage of F$DELTA_TIME -- it's already in V7.3-2

Cheers,
Robert
Master you were right about 1 thing -- the negotiations were SHORT!