Directory Purge Utility
From athena
On Athena5 (aka. p5) the script /local/opt/purgedir/purgedir may be used to report and/or delete files older than a specified threshold. The full manpage is listed below, and may be seen via "purgedir --man", but the general usage is "purgedir --age=days --warn --delete dir ..." This script can be run "by-hand" as needed, or could be set up to run as a cron job via a cron.d file similar to below:
/etc/cron.d/purgedir:
# 3AM Mon: Report impending deletions 0 3 * * 1 root /local/opt/purgedir/purgedir --age=14 --warn /psfs/fc-scr-1/scratch1/* 0 3 * * 1 root /local/opt/purgedir/purgedir --age=14 --warn /psfs/fc-scr-2/scratch2/* # 3AM Tue: Do deletions one day later 0 3 * * 2 root /local/opt/purgedir/purgedir --age=15 --warn --delete /psfs/fc-scr-1/scratch1/* 0 3 * * 2 root /local/opt/purgedir/purgedir --age=15 --warn --delete /psfs/fc-scr-2/scratch2/*
[edit] Purgedir Manpage
NAME purgedir - report and purge old files SYNOPSIS purgedir [--warn] [--delete] --age=days dir ... DESCRIPTION purgedir walks recursively through a given list of directories search- ing for and optionally deleting any regular files older than a speci- fied threshold age. If desired, a report of the identified "old" files for each directory will be written to a file with the same name plus a .purge suffix. Note that directories, symlinks and special files are neither reported nor deleted. OPTIONS purgedir supports the following command-line options: -a, --age=days (REQUIRED) Sets the threshold for what is to be considered and "old" file. The threshold is set to be days*24hr before the start of script execution. -w, --warn For each directory processed, a report file named dir.purge is created containing the list of "old" files to be deleted. --delete For each directory processed, purgedir will actually attempt to delete the "old" files. Without this option, no deletions are performed. -q, --quiet Sets the verbosity level to âquietâ. -v, --verbose Increases the verbosity level. -d, --debug[=n] Increases [sets] the debug level. -V, --version Prints the program version and exits. --help Prints a brief help message and exits. --man Prints the full manual page and exits. AUTHOR W. R. Somsky <somsky@phys.washington.edu>