Operating System - OpenVMS
1828481 Members
3184 Online
109978 Solutions
New Discussion

Re: Problem requeing a batch job

 
SOLVED
Go to solution
Jorge Cocomess
Super Advisor

Problem requeing a batch job

Greetings,

I have this batch job that only supposed to runs from Sunday through Thursday, skips the weekend. In my batch job, I have s section where it was checking for the day "THU" skip to the skip_weekend: prompt. However, it's not working like I thought it would do. Can someone direct me to the right commands.

$ wkday = f$edit(f$extract(0,3,f$cvtime("today",,"weekday")),"upcase")
$ if (wkday .eqs. "THU") then goto SKIP_WEEKEND

Thank you in advance.

Jorge
11 REPLIES 11
Ken Robinson
Valued Contributor
Solution

Re: Problem requeing a batch job

That should work, but we need more information as to what is happening, what does the rest of your code do, what errors are being generated?

But, why make it complicated?

$ wkday = f$cvt(,,"weekday")
$ if wkday .eqs. "Thursday" then goto skip_weekend

should work just as well.

Ken
Peter Zeiszler
Trusted Contributor

Re: Problem requeing a batch job

Is this running on a cluster right around midnight?

If a cluster node is even a fraction of a second different than where the queue manager runs - then you are technically running it the day before.

Why not check if Day = Fri or Sat then goto skip weekend?
Your script currently looks like it will only skip if day = Thursday. That might be related to when to resubmit.
Jorge Cocomess
Super Advisor

Re: Problem requeing a batch job

No, this is a non-cluster environment. No errors, just doesn't check for Thursday and it continue to submit the job for Friday and so on.

Thanks,
Jorge
EdgarZamora_1
Respected Contributor

Re: Problem requeing a batch job

I've encountered some weirdness in some lexical functions like f$cvtime when you bury them in complex commands, especially when running in batch. Try separating the f$cvtime out of that line and putting the result in a symbol that you'll then use in the f$extract. Better yet, do the simpler command that Ken recommended.

Jorge Cocomess
Super Advisor

Re: Problem requeing a batch job

Great suggestion! And yes, I did used Ken's suggetion and now it's working just the way I thought it would be.

Cheers!!

Jorge
Jorge Cocomess
Super Advisor

Re: Problem requeing a batch job

Okay, I thought it was working like the way I had intented. Anyways, I have to ask another question though, because the batch job resubmit it 2 consecutive days in a row. Here's the part of my script (below). Please let me know how I can fix this.

Thank you!!
$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$ set noverify
$ ON ERROR THEN GOTO EXIT
$ SET NOON
$ Set Proc/Priv=bypass
$!
$ wkday = f$cvt(,,"weekday")
$ if wkday .eqs. "Friday" then goto skip_weekend
$!
$ submit/user=backups/que=backups$batch -
disk5:[backups.com]full_backup.com -
/log=disk5:[backups.log]full_backup.log -
/after="tomorrow+15:00:00" /noprint

$!
$ Go To Begin
$ SKIP_WEEKEND:
$ submit/user=backups/que=backups$batch -
disk5:[backups.com]full_backup.com -
/log=disk5:[backups.log]full_backup.log -
/after="tomorrow+1-15:00:00" /noprint

$!
$ BEGIN:
$ set proc/name="Daily_Full_Backup"
$!

Doug_81
Frequent Advisor

Re: Problem requeing a batch job

Your code is working as expected. If it 's Friday, it will goto SKIP_WEEKEND. However, after it gets there, it will fall through to the BEGIN section and therefore, run it anyway.

Place the following immediately before the BEGIN label
$ goto exit
This is of course assuming that you have an EXIT label.

Also, I notice that you set an on error condition at the begining and then turn it off (set noon). Remove the "$ SET NOON" line.

However, you still have not corrected the problem that Peter mentioned. You are only checking for one day (Friday). When this runs on Saturday or Sunday, it will fail the check and not skip weekend.

Ideally, I would change your check to if Day = Saturday or Sunday then goto skip weekend.

Doug
Jim_McKinney
Honored Contributor

Re: Problem requeing a batch job

The following will execute the backup on any day whose name does not begin with an "S" - I think that's your goal.

$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$ set noverify
$ set noon
$ set proc/priv=bypass
$!
$ submit/user=backups/que=backups$batch -
disk5:[backups.com]full_backup.com -
/log=disk5:[backups.log]full_backup.log -
/after="tomorrow+15:00:00" /noprint
$!
$ if f$extr(0,1,f$cvti(,,"weekday")) .eqs. "S" then exit
$!
$BEGIN:
$ set proc/name="DailyFullBackup"
$!

Note that your process name was too long - 15 characters is the maximum and that unless you're issueing a later "SET ON" your "ON ERROR" trapping will never be activated.
Jorge Cocomess
Super Advisor

Re: Problem requeing a batch job

Great suggestions!! I will focus more on checking for weeknd "S" instead of weekdays.

Thank you so much!!

Jorge
Jorge Cocomess
Super Advisor

Re: Problem requeing a batch job

One other thought came to mind; I want to run this batch job every day with an exception "Sat" Saturday.

What would be the syntax setting this way?

Thanks,
Jorge
Doug_81
Frequent Advisor

Re: Problem requeing a batch job

$ if f$cvt(,,"weekday") .eqs. "Saturday" then goto skip_weekend