Can we find yesterday data (backup) regardless when we are running the script today?





Is there any alternative on solaris ?(-daystart option is not available on soalris OS)

Unless -daystart option is used [Gnu find only], time in Unix find is measured in 24 hour periods from the current moment.


Can we find yesterday data (backup) regardless when we are running the script today?

#!/bin/sh -x
touch -t 201005240000 today.ref
touch -t 201005250000 yesterday.ref
find . -newer yesterday.ref -a \! -newer today.ref -print
rm today.ref yesterday.ref

above lists files for one day,thats is 24052010 data it will display.



#!/bin/sh -x
touch -t `date '+%m%d'0000` /tmp/today.ref
last_mod=`stat -c %Y /tmp/today.ref`
times=`expr $last_mod - 86400`
time1="1970-01-01 UTC $times seconds"
ntime=`date -d "$time1" +"%Y%m%d"0000`
touch -t $ntime /tmp/yesterday.ref
echo "`date`">>/tmp/find_log
find . -newer /tmp/yesterday.ref -a \! -newer /tmp/today.ref -print | xargs
tar cvf output_$ntime.tar >>/tmp/find_log
rm /tmp/today.ref /tmp/yesterday.ref 1> /dev/null 2>>$MDS_DATA/temp/find_log

Here we used 'epoch time to normal time' conversion for as touch command option.

date -d '1970-01-01 UTC 1274725800 seconds' +"%Y-%m-%d %T %z"


sources:
http://www.softpanorama.org/Tools/Find/selecting_files_by_age.shtml

No comments :

Post a Comment