Scrubbing local scratch space
Scrubber Design
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:
/scratch/UserA/ (999)
fileA (5)
dirA/ (8)
fileB(7)
fileC(4)
fileD(7)
dirB/ (3)
dirC/ (99)
dirD/ (88)
dirE/ (66)
.keep (66)
dirF/ (66)
fileE (66)
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.
Test case
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.
--
CarstenAulbert - 03 Jan 2011