http://qs321.pair.com?node_id=699418


in reply to rm old directory

unix%> /usr/bin/find . -type d -mtime +60 -exec /bin/rm -rf {} \;

Edited: per moritz's suggestion, recommend "mtime" instead of "atime" although it's all up to you...

Replies are listed 'Best First'.
Re^2: rm old directory
by moritz (Cardinal) on Jul 22, 2008 at 20:56 UTC
    Relying on atime is generally a bad idea. I for one disable atime tracking during mounting, because IMHO it's a bad idea to have a side effect from every read.

    On my box your script would thus remove many directories that should stay.

    So rather rely on mtime.

      This is probably an edge case, but we had a tftp directory that we were cleaning up based on last modified time. The problem we ran into is that Windows/Samba and Konqueror all maintained the original timestamps on the file. So when someone copied a file created back in 2006 over to the system it got deleted fairly quickly!

      Our workaround was to make sure the files were not being backed up and then use the last access time instead of the last modified time.