find -mtime +7

Dear all,

find $ADMIN_DIR/$SID/arch/ -name '*.gz' -mtime +7 -exec rm {} \;

is it retaining 7 days OR 8 days .gz files ?

Thanks
Prakash

Please read man pages before posting any conceptual related topics.

Your command will remove .gz files which are modified before 7 days.

HI Thanks for the reply.

i have read man page but i could not got the answer

oracle >find . -mtime +7 -type f -exec ls -1 {} \; | wc -l
0
oracle >date
Thu Dec 9 02:21:11 EST 2010
oracle >ls -ltr | head -3
total 128912952
-rw-r----- 1 oracle dba 7270252 Dec 1 22:31 qlatl_arch_R669400381_T1_S215905.arc.gz
-rw-r----- 1 oracle dba 7339519 Dec 1 22:42 qlatl_arch_R669400381_T1_S215906.arc.gz

i am not able to understand why dec 1 files are not dispalayed in find . -mtime +7 -type f -exec ls -1 {} \; | wc -l

can you help me to understand how find command do is there any calculation is there ?

Thanks in advance.
Prakash

oracle >find . -mtime +7 -type f -exec ls -1 {} \; | wc -l

is it l(L) or 1(One) in above your code??

try

oracle >find /path/oracle -mtime +7 -type f -exec ls -l {} \;

Hi,

it is l(L) and not 1(one)

oracle >find /mounts/qlims_adc_arch/qlatl -mtime +7 -type f -exec ls -l {} \;
oracle >find . -mtime +7 -type f -exec ls -l {} \;
oracle >pwd
/mounts/qlims_adc_arch/qlatl

it is not returing rows

Thanks
Prakash

swap the position of type and mtime. actually I m outside right now and don't have access to any UNIX machine. so I cant test and then tell u, but try this.

find /mounts/qlims_adc_arch/qlatl -type f -mtime +7 -exec ls -l {} \;

Hi,

no luck for

oracle >find /mounts/qlims_adc_arch/qlatl -type f -mtime +7 -exec ls -l {} \;

yeah what i think is there should be calculation how find command will do what you say ?

Thanks
Prakash

didn't get u

+7 means you are looking for a file modified 7 days ago so this is 8 -9 -10 ..... day old files

Calculate older 7 days mean minimum 8 day and more older files

# after7=$(perl -e 'use POSIX;print strftime "%Y/%m/%d-%H:%M\n",localtime time-((7+1)*24*60*60);')
# echo $after7
2010/12/01-10:14
# touch -t 201012011012 TESTOLD

I can list TESTOLD file because its modif time is old from 2010/12/01-10:14

# find . -mtime +7 -type f -exec ls -1 {} \;|sort
./a
./al
./al1
./a.out
./b
./c
./lntest/a
./lntest/b
./TESTOLD
# touch -t 201012011020 TESTNEW

Like seen TESTNEW is not here because its modif time is new from 2010/12/01-10:14

# find . -mtime +7 -type f -exec ls -1 {} \;|sort
./a
./al
./al1
./a.out
./b
./c
./lntest/a
./lntest/b
./TESTOLD
 

Regards
ygemici

1 Like

Hi ygemici,

thanks for your time and valuable explanation about find command, i am really apperciated.

Thanks
Prakash

Don't forget that the definition of a day is 24 hours from the time the "find" command starts. This is detailed in an obscure manner in "man find".