check files updation

Hi All,

Can anyone help to write the script to check files updation?

i have files as mentioned below. which will be updated some time.

i just want to check the last file is updating the data for last 15 mins or not.

if its not updating i want to print NOT OK. if its updating data i want to print OK

files ex

-rw-rw-rw-   1 lscpusr  lscpusr      120 May 19 10:08 CDR_55000_19_05_2010_10_08_48.log
-rw-rw-rw-   1 lscpusr  lscpusr      111 May 20 11:32 CDR_50000_20_05_2010_11_32_53.log
-rw-rw-rw-   1 lscpusr  lscpusr      120 May 24 16:55 CDR_45000_24_05_2010_16_55_19.log
-rw-rw-rw-   1 lscpusr  lscpusr      120 May 25 16:57 CDR_55000_25_05_2010_16_57_29.log

pls help me to write the script.

Thanks.

the below script is for present time upation. but i want the script for last 15mins

dt7=`date '+%D'`
F1=`ls -ltr | tail -1 | awk '{print $7}'`
if [ "$F1" == "$dt7" ]
then
echo " FILES update STATUS : NOT OK" >>/tmp/Healthcheck_$dt.log
else
echo " FILES update STATUS :  OK" >>/tmp/Healthcheck_$dt.log
fi

15 minutes is 900 seconds. Get now in epoch seconds the last mtime of the file in epoch seconds. subtract. if the result > 900 seconds the file was not updated in the last 15 minutes.

now=$(date +%s)
ftime=$(date -r filename  +%s)
$d=(echo "$now  $ftime" | awk '{ print $1 - int($2) }' )
if [ $d -gt 900 ] ; then
   echo 'File not updating'
else 
   echo 'file OK'   
fi