-atime any pitfalls to using it to find out last time file accessed?

Posted on 2006-10-22
Last Modified: 2010-05-19
I have the below which I ran to find files older then 90 days but my results don't seem accurate (from glancing at output file)?

find / -type f -name "*.jpg" -o -name "*.jpe" -o -name "*.JPE" -o -name "*.JPG" -o -name "*.MOV" -o -name "*.mov" -o -name "*.mpg" -o -name "*.MPG" -o -name "*.mpeg" -o -name "*.mp3" -o -name "*.MP3" -o -name "*.mp4" -o -name "*.MP4" -o -name "*.gif" -o -name "*.GIF" -o -name "*.zip" -o -name "*.flv" -o -name "*.fla" -o -name "*.png" -o -name "*.PNG" -o -name "*.pdf" -o -name "*.PDF" -o -name "*.swf" -o -name "*.SWF" -o -name "*.wma" -o -name "*.WMA" -o -name "*.wmv" -o -name "*.WMV" -o -name "*.wav" -o -name "*.WAV" -o -name "*.avi" -o -name "*.AVI" -o -name "*.bmp" -o -name "*.BMP" -atime +90 > oldfiles.txt

Can anyone see any issues with this?
Question by:894359
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 45

Expert Comment

ID: 17783046
Hi 894359,

Command looks good .. why do you think this is not right? What are the inconsistencies in the result?

LVL 43

Expert Comment

ID: 17783301
> -name "*.BMP" -atime +90
are connected with -and by default. And 'and' operator is stroneger than 'or'. Therefore the '-atime +90' applies to *.BMP files only. Also I suggest You to use single quotes instead doubles.
find / -type f -a \( -name '*.jpg' -o ...... \) -a -atime +90 # is it better?


Author Comment

ID: 17784645
Hi ravenpl.. are you saying that my find only applies  the -aname  +90 to bmps andwill list all other file extentions listed?

So it should look somewhat like this? Confused by the two additional  "-a" added also????

find / -type f -a \(-name '*.jpg' -o -name '*.jpe' -o -name '*.JPE' -o -name '*.JPG' -o -name '*.MOV' -o -name '*.mov' -o -name '*.mpg' -o -name '*.MPG' -o -name '*.mpeg' -o -name '*.mp3' -o -name '*.MP3' -o -name '*.mp4' -o -name '*.MP4' -o -name '*.gif' -o -name '*.GIF' -o -name '*.zip' -o -name '*.flv' -o -name '*.fla' -o -name '*.png' -o -name '*.PNG' -o -name '*.pdf' -o -name '*.PDF' -o -name '*.swf' -o -name '*.SWF' -o -name '*.wma' -o -name '*.WMA' -o -name '*.wmv' -o -name '*.WMV' -o -name '*.wav' -o -name '*.WAV' -o -name '*.avi' -o -name '*.AVI' -o -name '*.bmp' -o -name '*.BMP'\) -a  -atime +90 > oldfiles.txt
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

LVL 43

Expert Comment

ID: 17786650
That's what I'm suggesting. Also '-type f' applied to '*.jpg' only ;)
-o == OR, -a == AND # it just reads better
LVL 38

Expert Comment

ID: 17786990
I suggest you to use "-mtime" or "-ctime" instead of "-atime".  The  access  time  of directories in path is changed by the  find command itself.

man find
to learn more deatils
LVL 43

Expert Comment

ID: 17787010
> I suggest you to use "-mtime" or "-ctime" instead of "-atime".  The  access  time  of directories in path is changed by the  find command itself.
Only for directories. For files it stays untouched. stat(filename) does not update atime.

Author Comment

ID: 17792120
Not following what you mean here/

Also '-type f' applied to '*.jpg' only ;)
-o == OR, -a == AND # it just reads better
LVL 43

Accepted Solution

ravenpl earned 500 total points
ID: 17793716
> Not following what you mean here
Then focus

You can type
find / -type f -name '*.jpg' -name '*.JPG' # which means same as
find / -type f -a -name '*.jpg' -a -name '*.JPG' # because -a means AND, and it's default operator(when no operator)
also, AND has higher precedence, so
find / -type f -name '*.jpg' -name '*.JPG' -o -type d #means same as
find / \( -type f -name '*.jpg' -name '*.JPG' \) -o -type d # where I assume You know what parens do?

So in Your first example parens and -a are like
find / \( -type f -a -name "*.jpg" \) -o -name "*.jpe" -o -name "*.JPE" -o -name "*.JPG" -o -name "*.MOV" -o -name "*.mov" -o -name "*.mpg" -o -name "*.MPG" -o -name "*.mpeg" -o -name "*.mp3" -o -name "*.MP3" -o -name "*.mp4" -o -name "*.MP4" -o -name "*.gif" -o -name "*.GIF" -o -name "*.zip" -o -name "*.flv" -o -name "*.fla" -o -name "*.png" -o -name "*.PNG" -o -name "*.pdf" -o -name "*.PDF" -o -name "*.swf" -o -name "*.SWF" -o -name "*.wma" -o -name "*.WMA" -o -name "*.wmv" -o -name "*.WMV" -o -name "*.wav" -o -name "*.WAV" -o -name "*.avi" -o -name "*.AVI" -o -name "*.bmp" -o \( -name "*.BMP" -a -atime +90 \)

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. Please see for the updated article. It is avail…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question