Scrubbing local scratch space
Imagine a local partition which is quite crowded and needs to be cleaned. Cleaning should be performed based on file age and possibly on a per directory bases (except top level directory). Also, if a user knows a certain part of the data needs to stay there, the scrubber must not delete this data - but may record it for further processing.
Let's start with an example, numbers in parenthesis are file ages in arbitrary units:
And now imagine we want to delete everything which is older than 6 time units, thus we would like to delete fileB,fileD,dirC,dirF and fileE. dirD and DirE
needs to stay because of the .keep file which marks a directory as important.
Run this script
to create above situation under /tmp/testcase, note that it sets both access and modification times into the past and uses "days" as the unit.
- 03 Jan 2011