Solved

How to display the last time files were accessed.

Posted on 2004-10-12
4
1,496 Views
Last Modified: 2013-12-27
I need a way to show the last time (date) each .sqr file was accessed on a solaris 9 server.  It seems there is a difference between the last time modified, and last time accessed.  What I need to know, if possible, is if a file was read or modified, or both  (We have a group of developers that have tons of .sqr files, some that are very old, and are not in use any more.   I need to identify files that no one has even read in the last year).  

I tried using:

find /  -name *.sqr -atime -365

but that seems to show only files that were accessed on a specified date, instead of listing the access time of every .sqr file.

Ultimately, these .sqr files need to be grouped by user, and then listed by the last time it was read or modified
 
Please let me know if I need to provide any other information.

Thanks for your help!
Juliann  

0
Comment
Question by:juli_ann
[X]
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
  • 2
4 Comments
 
LVL 21

Expert Comment

by:tfewster
ID: 12293520
"last access time" depends on the process that accesses the file updating the inode with the timestamp;  To be honest, I don't know what system utilities do and don't do that, so it's not very reliable :-(

find /  -name *.sqr -atime -365   should list all files accessed within the last year;  To display the actual access time, use `ls -lu` or `ls -tu`

0
 

Assisted Solution

by:colinbo
colinbo earned 125 total points
ID: 12293572
How about:
find /  -name *.sqr -exec ls -alu {} \;

This will unfortunately list all .sqr files, but will list them in order of time last accessed. You could redirect the output to a text file then sort it or grep from it manually from there. HTH

- CB
0
 
LVL 4

Assisted Solution

by:Otetelisanu
Otetelisanu earned 125 total points
ID: 12294827
find . ! -newer . -exec ls -l {} \; |tail -1

The find command has a -newer expression which compares the found files against a reference file. It returns files with a modification time newer than the reference file. To find older files, preceed the -newer expression with the negation operator !.

If you do not have a file to use with an appropriate timestamp, you can create a file with this recipe: Create/modify a UNIX file with an arbitrary timestamp.
0
 
LVL 21

Accepted Solution

by:
tfewster earned 250 total points
ID: 12296407
find /  -type f -name "*.sqr" -atime +365 -exec ls -ldu {} \;

-type f  excludes directories - `find` updates the access time on a directory when it reads it. However, the -name "*.sqr" probably makes this unnecessary.

-atime +365  only files accessed > 365 days ago

-exec ls -ldu {} \;   lists the details of the file, with the _access_ time instead of the _modification_ time.  The list is not sorted, as the "ls" is done on each file as `find` finds it.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.
Suggested Courses

623 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