Solved

How to display the last time files were accessed.

Posted on 2004-10-12
4
1,483 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
  • 2
4 Comments
 
LVL 20

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 20

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AIX print queues constantly going down 11 489
AIX  NFS  question 1 119
Remote Change Dates on AIX Automation 7 51
MarkLogic 1 68
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now