to check files updation in sys time

Dear All,

Pls help me on this issue.

i want to write a script to check whether files updation happening in cuttent time or not.
i have set of files in directory which wil update in time basis..

Requirement: If the files are updating in system time i just want to print "files are updating" . If its not updating i just want to print "Files not updating in current time"

ex :

-r--r--r--   1 lscpusr  lscpusr  10000107 Aug 23 13:31 SCP_23_08_2010_13_23_21.log
-r--r--r--   1 lscpusr  lscpusr  10000108 Aug 23 13:39 SCP_23_08_2010_13_31_19.log
-r--r--r--   1 lscpusr  lscpusr  10000150 Aug 23 13:47 SCP_23_08_2010_13_39_20.log
-r--r--r--   1 lscpusr  lscpusr  10000110 Aug 23 13:56 SCP_23_08_2010_13_47_38.log
-r--r--r--   1 lscpusr  lscpusr  10000066 Aug 23 14:04 SCP_23_08_2010_13_56_04.log
-r--r--r--   1 lscpusr  lscpusr  10000020 Aug 23 14:12 SCP_23_08_2010_14_04_24.log
-r--r--r--   1 lscpusr  lscpusr  10000056 Aug 23 14:20 SCP_23_08_2010_14_12_28.log
-r--r--r--   1 lscpusr  lscpusr  10000094 Aug 23 14:28 SCP_23_08_2010_14_20_32.log
-r--r--r--   1 lscpusr  lscpusr  10000227 Aug 23 14:36 SCP_23_08_2010_14_28_31.log
-r--r--r--   1 lscpusr  lscpusr   4150442 Aug 23 14:39 SCP_23_08_2010_14_36_32.log

PLs help on this issue.

Thanks in advance.

I'd gladly help you if i just could understand what you want. Could you please elaborate on what your requirement is and what you intend to do with this directory listing?

bakunin

Thanks bakunin,

Actually files will be generated in time basis in the directory named "backup".
maximum file size is 10MB. if it reach 10MB it will write another file that i mentioned code below.

i want to write a program to check these files. whether these files are updating regularly or not. it should update regularly. if it is update regularly i need to print in echo " files are updating " ... if its not updating last 15 mins , i want to print in echo " files not updating"

r--r--r--   1 lscpusr  lscpusr  10000108 Aug 23 13:39 SCP_23_08_2010_13_31_19.log
-r--r--r--   1 lscpusr  lscpusr  10000150 Aug 23 13:47 SCP_23_08_2010_13_39_20.log
-r--r--r--   1 lscpusr  lscpusr  10000110 Aug 23 13:56 SCP_23_08_2010_13_47_38.log
-r--r--r--   1 lscpusr  lscpusr  10000066 Aug 23 14:04 SCP_23_08_2010_13_56_04.log
-r--r--r--   1 lscpusr  lscpusr  10000020 Aug 23 14:12 SCP_23_08_2010_14_04_24.log
-r--r--r--   1 lscpusr  lscpusr  10000056 Aug 23 14:20 SCP_23_08_2010_14_12_28.log
-r--r--r--   1 lscpusr  lscpusr  10000094 Aug 23 14:28 SCP_23_08_2010_14_20_32.log
-r--r--r--   1 lscpusr  lscpusr  10000227 Aug 23 14:36 SCP_23_08_2010_14_28_31.log
-r--r--r--   1 lscpusr  lscpusr   4150442 Aug 23 14:39 SCP_23_08_2010_14_36_32.log

pls look the bold marked timing in code.. i want to compare file time with system time.. basic thing in this directory is files will update till it reach 10MB. after tht i'll write another file. i want to compare system timing with latest file.

Hope you understand my requirement.

Pls reply for if u want more clarity.

Something like this,

#!/bin/sh

while true
do
var=`find /backup -name "SCP_*.log" -type f -mmin -15`
if [ -z $var ]
then
 echo "File Not Updating"
else
 echo "Success : File Updating"
fi
sleep 300
done
#!/bin/bash
eval $(stat -s file)
[ $st_ctime -lt $(($(date "+%s") - 900)) ] && echo No update || echo Update

Dear pravin27..

Thanks.. but i'm getting some bugs. pls check the code and suggest me.

bugs:

find: bad option -mmin
find: [-H | -L] path-list predicate-list

Thanks in advance.

Try this,

#!/bin/sh

while true
do

TSTAMP=$(perl -e '($ss, $mm, $hh, $DD, $MM, $YY) = localtime(time() - 900);
printf "%04d%02d%02d%02d%02d", $YY + 1900, $MM + 1, $DD, $hh, $mm')

touch -t $TSTAMP file1
var=`find /backup -name "SCP_*.log" -type f -newer file1`
if [ -z $var ]
then
 echo "File Not Updating"
else
 echo "Success : File Updating"
fi
sleep 120
done