Re: finding files modified yesterday

From: Holger.VanKoll@SWISSCOM.COM
Date: Tue Dec 10 2002 - 11:01:16 EST


that might work (I did not check for handling of daylight saving), but
as I said I dont (always) know the TZ.
 
I need a solution that runs on every aix node, no matter what TZ, LC*
 
I am not the first who had this problem... obviously its not that easy
to solve.
something like
perl -MPOSIX -le 'print strftime("%Y %m %d", localtime(time-24*60*60))'
might work, but then I have to rely on perl being installed...
 
this http://pcunix.com/Bofcusm/1455.html
also looks good. it uses cal , part of bos.rte.misc_cmds ; dunno if I
can rely on it being installed
 
this script also looks good, but I dont understand it ;-)
localtime=$(date +%H)
utc=$(date -u +%H)

offset=$(($utc - $localtime))
today=$(TZ="EST${offset}EDT${offset}" date +%Y%m%d)

offset=$(($offset + 24))
yesterday=$(TZ="EST+${offset}EDT+${offset}" date +%Y%m%d)

offset=$((48 - $offset))
tomorrow=$(TZ="EST-${offset}EDT-${offset}" date +%Y%m%d)

echo "YESTERDAY=$yesterday"
echo "TODAY=$today"
echo "TOMORROW=$tomorrow"

if you understand it: will it handle daylight-saving and leap years?
 
 
this also looks good:
ECHO="/usr/bin/echo"
DATE="/usr/bin/date"
${ECHO} "`(TZ=Yes+24:00:00 ; export TZ ; ${DATE} $*)`"
 
but as I dont understand this TZ-stuff I have the same question: will it
handle daylight-saving and leap years?
 
 
 
 
 

        -----Original Message-----
        From: Green, Simon [mailto:SGreen@KRAFTEUROPE.COM]
        Sent: Tuesday, December 10, 2002 4:39 PM
        To: aix-l@Princeton.EDU
        Subject: Re: finding files modified yesterday
        
        
        You're on the right track. Use touch -t, but set it to midnight
yesterday.
        Using one of my systems in Switzerland, (I assume that's where
you are):
         
        echo TZ
        MET-1METDST,M3.5.0,M10.5.0
         
        touch -t `ksh TZ=MET23METDST,M3.5.0,M10.5.0 date +%m%d`0000
/tmp/timestamp
         
        To see yesterday's date, just add 24 to the TZ offset and let
date take care of the rest.
         
        If you were smart, you could probably write a script to
automatically generate an appropriate TZ parameter for any given
offsest. I'm not sure it's worth the effort, though.
         
        Using this with find will give you everything modified since
midnight yesterday, including files modified today. I'm not sure that
there's any easy way of avoiding that, but you ought to be considering
that a file that was modified yesterday was *also* modified today.
         
        If you have a lot of files and really only want those modified
yesterday you could generate two lists - one for files modified since
midnight yesterday; one for midnight today - and run comm against them.
        
        Simon Green
        Philip Morris ITSC Europe
        
        AIX-L Archive at http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2
        AIX FAQ at http://www.faqs.org/faqs/aix-faq/
        
        N.B. Unsolicited email from vendors will seldom be appreciated.

                -----Original Message-----
                From: Holger.VanKoll@SWISSCOM.COM
[mailto:Holger.VanKoll@SWISSCOM.COM]
                Sent: 10 December 2002 14:38
                To: aix-l@Princeton.EDU
                Subject: finding files modified yesterday
                
                

                Hello,

                I need to find all files in /somewhere that have been
modified yesterday.

                So far I use touch -t todays_date_0:00 /tmp/timestamp
and find -new /tmp/timestamp to find all files modified earlier than
today.

                How can I filter out the files modified 2,3,4... days
before?
                I should have a way that does not rely on certain TZ or
LC* settings.



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:24 EDT