Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to display the last time files were accessed.

Posted on 2004-10-12
4
Medium Priority
?
1,509 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 500 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 500 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 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

670 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