Need Suggestion, on how to constantly moniter a file and display content with in that time

Dear Gurus,

I'm in a strange situation, hence need some kind of advice or possible syntax to carry on.

let's say

current time/date is 2013-12-18, 15:58:15

I got a file something like this, which keep getting updated with respect to time.

2013-12-18, 15:56:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736
2013-12-18, 15:57:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736
2013-12-18, 15:58:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736
2013-12-18, 15:59:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736
2013-12-18, 14:15:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736
2013-12-18, 14:23:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736

So, now I will run the script then it should sum the duration in my file from (current time - 5mins)
hence it should sum

2013-12-18, 15:56:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736
2013-12-18, 15:57:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736
2013-12-18, 15:58:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736
2013-12-18, 15:59:15,[http-3],USERNAME,SUCCESS,DURATION,815,EXECUTE,CELLS,1736

so every time if it runs then that moment it will go to file and subtract 5 mins from the current system time and only display sum of duration falling this time range(i.e. with in system date and system date - 5mins).

I would like to make in UNIX scripting.

Specify your OS

uname -a

sorry it is GNU/Linux, 2.6.32.59-0.7-default

Using ksh93 printf %T formatting option:

#!/bin/ksh93

c_ts=$( printf "%(%s)T" "now" )

while IFS=, read dt tm skip
do
        f_ts=$( printf "%(%s)T" "${dt} ${tm}" )
        d_ts=$(( $c_ts - $f_ts ))
        [ $d_ts -le 300 ] && print "${dt},${tm},${skip}"
done < file

Thanks at the moment it's working.