1828745 Members
2748 Online
109985 Solutions
New Discussion

Re: --com file --

 
SOLVED
Go to solution
Mrityunjoy Kundu
Frequent Advisor

--com file --

pls. send me com file by which i a batch job automatically run every day in a week at 1:00 hrs
3 REPLIES 3
Heinz W Genhart
Honored Contributor
Solution

Re: --com file --

Hi mrityunioy

Hope the following code helps

$ sav_ver=F$VERIFY(0)
$ debug=0
$ IF F$TRNLNM("command_debug") THEN debug=1
$ IF debug THEN SET VERIFY
$! ----------------------------------------------------------------------------------------------
$! Title: Resubmit.com
$! Author: Heinz Genhart
$! Creation Date: 11-SEP-1995
$! Modification Date: .
$!
$! Description: This Commandfile is a framework for submitting a periodical Job
$! .
$! ----------------------------------------------------------------------------------------------
$ ON CONTROL_Y THEN GOTO clean_up
$ ON WARNING THEN GOTO clean_up
$ sts=1
$ sav_def=F$ENVIRONMENT("DEFAULT")
$ sav_mes=F$ENVIRONMENT("MESSAGE")
$ this_user=F$GETJPI("","USERNAME")
$ this_node=F$GETSYI("NODENAME")
$ this_proc=F$ENVIRONMENT("PROCEDURE")
$ mode=F$MODE()
$! ----------------------------------------------------------------------------------------------
$ SET NOON
$! ----------------------------------------------------------------------------------------------
$ job_name = "''F$PARSE(F$ENVIRONMENT("PROCEDURE"),,,"NAME")'" ! Name of Job
$ WRITE SYS$OUTPUT job_name
$ que_name = "SYS$BATCH" ! Name of Queue
$ interval = "+06:00:00.00" ! every 6 hours
$ interval = "TOMORROW+01:00:00.00" ! Ã very morning at 01:00
$! ----------------------------------------------------------------------------------------------
$!
$!
$! Delete Job if it already exists
$!
$ temp = F$GETQUI("")
$ this_entry = F$GETQUI("DISPLAY_JOB","ENTRY_NUMBER",,"THIS_JOB")
$ temp = F$GETQUI("")
$qloop:
$ qname = F$GETQUI("DISPLAY_QUEUE","QUEUE_NAME","*")
$ IF qname .EQS. "" THEN GOTO clean
$jloop:
$ noaccess = F$GETQUI("DISPLAY_JOB","JOB_INACCESSIBLE",,"ALL_JOBS")
$ IF noaccess .EQS. "TRUE" THEN GOTO jloop
$ IF noaccess .EQS. "" THEN GOTO qloop
$ jname = F$GETQUI("DISPLAY_JOB","JOB_NAME",,"FREEZE_CONTEXT,ALL_JOBS")
$ IF jname .EQS. "''job_name'"
$ THEN
$ entry = F$GETQUI("DISPLAY_JOB","ENTRY_NUMBER",,"FREEZE_CONTEXT,ALL_JOBS")
$ IF entry .NE. this_entry THEN DELETE/ENTRY='entry'
$ ENDIF
$ GOTO jloop
$clean:
$!
$! Then Submit the Job
$!
$ SUBMIT/NOLOG/NOPRINT/QUEUE='que_name'/NAME="''job_name'"/AFTER="''interval'" 'this_proc'
$!
$!
$! ----------------------------------------------------------------------------------------------
$!
$! #### Do here, what you want to do #####
$!
$! ----------------------------------------------------------------------------------------------
$clean_up:
$ SET DEFAULT 'sav_def'
$ SET MESSAGE 'sav_mes'
$ sav_ver=F$VERIFY(sav_ver)
$ EXIT 'sts'



Regards

Heinz
Hein van den Heuvel
Honored Contributor

Re: --com file --


'every day in a week' for me is the same a 'every day'. Best I know there are no days outside a week.
Did you mean every day?
Did you mean 'every day for this week'?
Did you mean 'every work day in this week' ?
What is a work day in your locale?

If you happen to mean every day excluding Saturday and Sunday, then you can try the simple example below. It is easily changed to 'every day' by dropping the lines testing for a day starting with "S" in the (English) name (In the Netherlands test for "Z", for other places.. oh well).

Be sure to check the nice, robust, code Heinz already posted. Try to understand it, and you may find that you really should put all the checks in place.

But if you just need a quick hack, try...


$this_file = f$environment("PROCEDURE")
$file = f$element(0,";",this_file) ! Drop specific version
$next = f$cvtim("tomorrow + 1:0:0","ABSOLUTE")
$if "S".eqs.f$ext(0,1,f$cvtime(next,,"WEEKDAY")) then next = f$cvtime(next + " +1-","ABSOLUTE")
$if "S".eqs.f$ext(0,1,f$cvtime(next,,"WEEKDAY")) then next = f$cvtime(next + " +1-","ABSOLUTE")
$submit/after="''next'" 'file ! Resubmit to default queue
$
$! Work starts here
$ show time
John Gillings
Honored Contributor

Re: --com file --

Hein,

>$this_file = f$environment("PROCEDURE")
>$file = f$element(0,";",this_file) ! Drop specific version

I've done it for years that way, but just recently realised it could be done "properly" like this:

$ this_file= F$PARSE(";",F$ENVIRONMENT("PROCEDURE"))

For a daily job that varies according to the weekends, I prefer this construct:

$ ! Resubmit for next day regardless
$ SUBMIT/AFTER="TOMORROW+0-1:0" F$PARSE(";",F$ENVIRONMENT("PROCEDURE"))
$ !
$ ! Commands to execute every day here
$ !
$ ! Dispatch to per-day
$ GOTO 'F$CVTIME(,,"WEEKDAY")
$
$ Saturday:
$ Sunday:
$ !
$ ! Commands to execute on weekend here
$ !
$ EXIT
$
$ Monday:
$ Tuesday:
$ Wednesday:
$ Thursday:
$ Friday:
$ !
$ ! Commands to execute on weekdays here
$ !
$ EXIT


Very easy to modify for specific things to be done on a particular weekday, and very obvious how it works.

(Hein's "S" tests are very clever, but it takes a minute or so to work out what it's doing and how it works).
A crucible of informative mistakes