Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subtracting times

Status
Not open for further replies.

gbell

MIS
Feb 19, 2002
86
AU
I'm trying to write a script to compute the run times of COBOL batch programs. I am restricted in that I am unable to put 'wrappers' around the job to capture the time.

We're using AUTOSYS to control the batching environment and I'm extracting the run information from the Monbro (Monitor Browser) logs. I can grep out the start time and the end time but I'm unsure of the best way of subtracting the start time from the end time to get the elapsed time.

Another complication is that the start time will be on one record, with the end time on the next record. Perhaps I'd be better off concatinating the two records into one record.

Any thoughts or help would be greatly appreciated.

Regards
Greg
 
> Another complication is that the start time will be on one record, with the end time on the next record
So long as you can match up pairs of start/end times, it shouldn't be much of a problem

If you have a time string like
"12:34:56"
then the following awk function will suffice

Code:
function time_in_seconds ( t1,       arr ) {
  split(t1,arr,":")
  return arr[1]*3600+arr[2]*60+arr[3]
}

You then do
ts = time_in_seconds("12:34:56")
te = time_in_seconds("12:35:42")
print "Elapsed time=", te-ts


It's only a minor enhancement to catch cases where the program runs across midnight.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top