?
Solved

When was file last accessed?

Posted on 2000-03-24
5
Medium Priority
?
270 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
[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
  • 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 400 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 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