0

I have an old storage with hundreds of user home directories. I want to reclaim some disk space by deleting all "old" home dirs. It's on a linux server, RHEL 6. I want to delete the entire home dir., but only if there are no files that have been create, modified, updated or accessed, in under 7 years. Does anyone have any idea how to build a script to do this?

Thankyou.

  • Using access time may not be reliable, as automated tools such as backup clients may have accessed such old files. – Michael Hampton May 22 '19 at 0:51
  • Thank you pointing out what could be a serious hurdle. At this point, I can hope and pray this will work as I have a lot of data to store. – Mike May 22 '19 at 21:50
0

I think you would need to author a bash script to do this if you need help with that it might be better asking on Stack Overflow because it's script development.

While this is possible if the distribution used supports atime some don't be the default they explicitly mount the filesystem with noatime in this case you would not be able to know when the file was last read and only when created or modified (updated is the same thing) the other option that is used but would work for you is realtime this would only update the file last accessed normally once per day.

To check this use ls -l --time=atime you can then use this in a bash script with ls -ls --time=atime | while read line

As I said above that is the tool you need if you need a script building to do this for you I would say you should be on stack overflow and not server fault while this is a server building a script falls more into the programming side than the server management side of the two sites.

  • Thank you for your reply. I have tried ls -l --time=atime and ls -l and the output looks the same. Im starting to think atime mite be too much to hope for. I'll try your other suggestion too. I'll repost on Stack Overflow. – Mike May 22 '19 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.