Find command to delete the files

Hi All,
I've created 2 files

touch -t 201309101234 aa10
touch -t 201309111234 aa11

Exact 60 days before from today date is SEPT 12th . As per the following command as i gave +60 means the files which were created before sept12th should be deleted

find /etc/logs/*aa* -type f -atime +60 -exec rm -f {} \;

But the above command is deleting only aa10 file and not the aa11 file ..
Could you please help me in this .

It works fine for me.

Is your system date correct?

What is the output of ls -lu /etc/logs/*aa* ?

Thanks for the reply scott

$ ls -lu *aa*
-rw-r--r--   1 techno tst            0 Sep 10 12:34 aa11
-rw-r--r--   1 techno tst            0 Sep 11 12:34 aa12

Thanks,

At the time you issue the command aa11 was exactly 60 instead of more than 60 since last time accessed.

find /etc/logs/*aa* -type f -atime 60 -exec ls -l {} \;

Thank you for reply aia

Today I executed the command . So I have given. +60means ., delete the data before Sept 12th .
but with the command I've given .. it is ins ble to delete aa11.
Please suggest.

Since you did not post your last given command I am going to guess and recommend that you tested first with:

find /etc/logs/*aa* -type f -atime +59 -exec ls -l {} \;

That should pick the files up that you have been using as example and list it for you. If it does then you can substitute the -exec ls -l for -exec rm -f.

1 Like