Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

When was file last accessed?

Posted on 2000-03-24
5
Medium Priority
?
272 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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 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…
Suggested Courses

618 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