Shell script to find the run time based on log entries?

Shell script to find the run time based on log entries?
Below is the log files content updated when the script test.sh runs. I would like to calculte the difference between first update time stamp and last update time stamp to find the run time of the script. The below log file shows the first update as 16:50 and last update 17:42.

Is there any way to find the run time with the difference between first update line and last update line.

l106:/opt/PATH� cat SETCSH_20101030_205037.log
2010-10-30 16:50:38,022 JobRunner.configure Complete
2010-10-30 16:50:38,022 JobRunner.runJob Start
2010-10-30 16:50:38,028 JSRCleaner.cleanJSRs Start
2010-10-30 16:50:38,028 JSRCleaner.cleanJSRs Removing JSRs older than 7 days
2010-10-30 16:50:38,191 JSRCleaner.cleanJSRs Complete
2010-10-30 16:50:38,405 JobRunner.invokeJob Start
2010-10-30 16:50:38,448 AbstractJobInvoker.invokeBatchJob Start
2010-10-30 16:50:38,519 AbstractJobInvoker.invokeBatchJob Complete
2010-10-30 16:50:38,519 JobRunner.invokeJob Complete
2010-10-30 16:50:38,519 JobRunner.monitorJob Start
2010-10-30 17:42:46,494 JobRunner.monitorJob Complete
2010-10-30 17:42:46,536 JobRunner.runJob Complete
2010-10-30 17:42:46,536 JobRunner.processMain Complete : Return Code 0

Hi,

Try this 'awk' solution:

$ cat script.awk
BEGIN {
  FS = "[ ,]"; 
} 

NR==1 { 
  datef = $1; 
  timef = $2; 
} 

END { 
  datet = $1; 
  timet = $2;

  split(datef, arrDatef, "-"); 
  split(datet, arrDatet, "-"); 
  split(timef, arrTimef, ":"); 
  split(timet, arrTimet, ":");
  utcDateTimeF = mktime(arrDatef[1] " " arrDatef[2] " " arrDatef[3] " " arrTimef[1] " " arrTimef[2] " " arrTimef[3]);
  utcDateTimeT = mktime(arrDatet[1] " " arrDatet[2] " " arrDatet[3] " " arrTimet[1] " " arrTimet[2] " " arrTimet[3]);
  printf "%s\n", strftime("%H:%M:%S", utcDateTimeT - utcDateTimeF, 1);
}
$ cat infile
2010-10-30 16:50:38,022 JobRunner.configure Complete
2010-10-30 16:50:38,022 JobRunner.runJob Start
2010-10-30 16:50:38,028 JSRCleaner.cleanJSRs Start
2010-10-30 16:50:38,028 JSRCleaner.cleanJSRs Removing JSRs older than 7 days
2010-10-30 16:50:38,191 JSRCleaner.cleanJSRs Complete
2010-10-30 16:50:38,405 JobRunner.invokeJob Start
2010-10-30 16:50:38,448 AbstractJobInvoker.invokeBatchJob Start
2010-10-30 16:50:38,519 AbstractJobInvoker.invokeBatchJob Complete
2010-10-30 16:50:38,519 JobRunner.invokeJob Complete
2010-10-30 16:50:38,519 JobRunner.monitorJob Start
2010-10-30 17:42:46,494 JobRunner.monitorJob Complete
2010-10-30 17:42:46,536 JobRunner.runJob Complete
2010-10-30 17:42:46,536 JobRunner.processMain Complete : Return Code 0
$ awk -f script.awk infile
00:52:08

Regards,
Birei