[SunHELP] script thats test on timestamp


Mon Jan 6 11:49:16 CST 2003


If you have the gnu date function, you can touch a file into existance with
a specific time of an hour ago, then use "find" with the -newer flag, ie:

#Note the /usr/local/bin/date is the Gnu date..
touch -t `/usr/local/bin/date --date="-1 hours" +%m%d%H%M` /tmp/touchfile
find /path/dir -type f -file <filespec> ! -newer /tmp/touchfile

If you're running this on a cron file hourly or something for a cleanup
process you can do it without the gnu date function

#!/bin/ksh
TFILE=/var/tmp/touchfile
if [ -f $TFILE ]
then
  find /path/dir -type f -file <filespec> ! -newer $TFILE
  ..do whatever..
fi
touch $TFILE

this'll find all files with <filespec> but will exclude files
created/modified since the previous run of the program.  Run it hourly and
you've got it.

HTH - Mark


-----Original Message-----
From: Simon Jespersen [mailto:shj at pine.dk]
Sent: Tuesday, December 17, 2002 7:55 AM
To: Sun solaris help list
Subject: [SunHELP] script thats test on timestamp


Hi! 
I need at script that test the time stamp on a normal text file. 

if [ timestamp > 60 min ] ; then
    do something here
fi

Does anyone have this small procedure in normal ksh or sh 
Kind regards
Simon Jespersen
Project engineer
Pine Tree Systems A/S
Damhaven 5d
DK-7100 Vejle
Email: shj at pine.dk
Phone: +4575724477 
_______________________________________________
SunHELP maillist  -  SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp


More information about the SunHELP mailing list