Solved

When was file last accessed?

Posted on 2000-03-24
5
261 Views
Last Modified: 2010-04-20
I know one can get info on file creation date; but can one find out when a particular file(s) have last been accessed?  I want to cron a proceedure to rm certain files not accessed for a predetermined amount of time.
0
Comment
Question by:RUSTY
  • 2
  • 2
5 Comments
 

Author Comment

by:RUSTY
ID: 2653662
Adjusted points from 50 to 100
0
 
LVL 4

Expert Comment

by:kiffney
ID: 2653702
if you're using gnu find, you could do

find /path/to/files -name '*' -atime +100

to find files that have not been accessed for more than 100 days.  If you added

|xargs rm -f

to the end of that line, that will delete them.  Use this with care, and remember that find descends the directory tree unless you also specify -maxdepth.
0
 
LVL 3

Expert Comment

by:alien_life_form
ID: 2653722
Greetings.

ls -u gives you that type of information.

Also:

find <dir> -type f -atime +3 | xargs rm

should remove all files not accessed in the last 3 days. Check it with man find, though it's untested code - I use something similar, but with -mtime (last modified).

Cheers,
   alf

0
 

Author Comment

by:RUSTY
ID: 2653843
Cool.  one problem: I'll be looking at files not accessed a certain amount of minutes or hours ago.  Is that feasable?
0
 
LVL 4

Accepted Solution

by:
kiffney earned 100 total points
ID: 2653970
Yes, instead of -atime use -amin and put in +100 for files not accessed for the past 100 minutes.  
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

856 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