Andrew Grady
Andrew Grady

Reputation: 1

find command with -atime appears to ignore dates

This command doesn't behave as I would expect. -atime +1 says "anything accessed within the last 24 hours", correct?

Output:

find . -type f -atime +1 -name 'installActions2*.log' | xargs ls -lt
-rw-r----- 1 bordb oinstall  369657 Nov 15 19:41 ./oms_b4_18604893.bak.15_Nov_14/cfgtoollogs/oui/installActions2014-03-17_09-18-01-PM.log
-rw-r----- 1 andy oinstall 1749422 Mar 17  2014 ./oracle_common/cfgtoollogs/oui/installActions2014-03-17_09-25-00-PM.log
-rw-r----- 1 andy oinstall  369657 Mar 17  2014 ./oms/cfgtoollogs/oui/installActions2014-03-17_09-18-01-PM.log
-rw-r----- 1 andy oinstall  600584 Mar 17  2014 ./jdk16/cfgtoollogs/oui/installActions2014-03-17_06-18-27PM.log

why are the files from March of 2014 and November showing up? So assuming the -atime switch says, "modified earier than the last 24 hours", I changed it to 60, and it lists the current directory, and all its files (ignores the -name switch) and doesn't traverse the subdirectories.

/ora/oracle/product/middleware_12cr3 Unix> find . -type f -atime +60 -name 'installActions2*.log' | xargs ls -lt
total 204
drwxr-xr-x 53 andy oinstall   4096 Jan  8 00:05 oms
drwxr-x--- 51 andy oinstall   4096 Jan  8 00:05 Oracle_WT
drwxr-x--- 33 andy oinstall   4096 Jan  7 22:09 oracle_common
drwxr-xr-x  2 andy oinstall   4096 Nov 20 07:45 logs
drwxr-xr-x 52 andy oinstall   4096 Nov 15 19:44 oms_b4_18604893.bak.15_Nov_14
drwxr-xr-x 10 andy oinstall   4096 Jun 18  2014 plugins
drwxr-xr-x  9 andy oinstall   4096 Jun  2  2014 wlserver_10.3
-rw-rw----  1 andy oinstall    520 Mar 18  2014 domain-registry.xml
drwxr-x---  3 andy oinstall   4096 Mar 18  2014 user_projects
drwxr-xr-x  5 andy oinstall   4096 Mar 17  2014 patch_wls1036
-rw-r--r--  1 andy oinstall   1826 Mar 17  2014 registry.xml
-rw-r--r--  1 andy oinstall    622 Mar 17  2014 ocm.rsp
-rw-r--r--  1 andy oinstall 108917 Mar 17  2014 registry.dat
drwxr-xr-x  8 andy oinstall   4096 Mar 17  2014 utils
drwxr-xr-x  7 andy oinstall  36864 Mar 17  2014 modules
drwxr-xr-x  6 andy oinstall   4096 Mar 17  2014 jdk16

anyone know the reason? Sorry if this not an advanced question.

Upvotes: 0

Views: 64

Answers (1)

dg99
dg99

Reputation: 5663

The -*time args to find consider time as growing larger in the past. So +1 means "more than one day ago", not "after one day ago". Try -1 to mean "less than one day ago".

Upvotes: 1

Related Questions