Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find files by access time

Status
Not open for further replies.

wtrepani

MIS
May 30, 2002
93
US
All,

I am working on migrating users from an older system to a newer one. One of the things I am doing is setting up scripts to get rid of users who do not use the system anymore. Because much of the data is very old, and many peoples scripts look at other peoples files, this is my problem.

I have a script written to disable a user account after 90 days of inactivity, and after 120 days, it deleted the account and chowns all the data to a generic olddata account. The group remains the same. What I want to do is periodically do a find on all data in these file systems for data owned by olddata that has not been accessed in 90 days. My problem is my understanding of the find command is that when you do a find ./ -atime, it modifies the access time. Therefore, if I run a find once a week, I will never find anything that hasn't been accessed in 90 days. Does anyone have an idea to get around this?

Thanks

Will
 
Will,

Not sure if this will help you:
Find all files updated since 'afile' was updated.
find . -newer afile -type f -exec file {} \;

I'm not a real deal UNIX guy but would you be able to use the touch command weekly so you don't modify the date?

Or Perhaps:
-mtime n
True if the file's data was modified n days ago.

I don't know how much I'm actually helping you here...

Best,
Matt
 
Matt,

Thanks for the advice, but unfortunately, many of these files are not updated, but only read. That is where my problem is. If I run
find ./ -atime +90 file -exec rm {} \;

It updates the last access time, so you only find files the first time you run it. After that, all files were accesses the last time you ran the find. I am not sure if a solution exists to do what I need it to, but any suggestions are welcome.

Thanks

Will
 
Will,

it depends whether other users access the files in the olddata area, but if not, just use the -mtime +90 option to find all files in the area not modified within the last 90 days. HTH.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top