3 # Copyright © 1995-1997, William M. Perry <wmperry@aventail.com>
5 # Author: William M. Perry <wmperry@aventail.com>
6 # Maintainer: William M. Perry <wmperry@aventail.com>
7 # Created: 95/04/18 10:44:15
9 # Modified: 1998/12/01 22:11:57
10 # Keywords: cache clean
12 # This shell script will clean out your cache directory for Emacs/W3
13 # It is designed to be run from a cron (see crontab(5)) or at(1) job.
15 # This should probably only be run occasionally: like once a month, or
16 # when you determine that the cache size is too big. Something like:
19 # SIZE=`du -s $CACHE_ROOT | awk '{print $1}'
20 # if [ $SIZE -gt $CACHEMAXSIZE ] ; then
21 # /run/the/real/clean-cache
24 if [ -z "$CACHE_ROOT" ] ; then
25 CACHE_ROOT=/tmp/$USER # The root directory of the cache
28 if [ -z "$CONTROL_FILE" ] ; then
29 CONTROL_FILE="$CACHE_ROOT/.clean"
32 if [ -z "$CLEAN_PROTOCOLS" ] ; then
33 CLEAN_PROTOCOLS="http gopher file ftp wais news"
36 if [ -f "$CONTROL_FILE" ] ; then
37 echo "Starting to clean $CACHE_ROOT..." `date`
39 for x in $CLEAN_PROTOCOLS
41 if [ -d "${CACHE_ROOT}/${x}" ] ; then
42 echo " Cleaning $x files"
43 find $CACHE_ROOT/$x -depth -type f \( ! -anewer "$CONTROL_FILE" \) \
45 find $CACHE_ROOT/$x -depth -type d -exec rmdir {} \;
50 echo "Cache clean ended: "`date`
52 echo "The cleaning control file ($CONTROL_FILE) could not be found."
53 echo "To create it (and make all your cache files 'current' do:"
55 echo "touch $CONTROL_FILE"
56 echo "find $CACHE_ROOT -exec touch {} \;"
58 echo "PLEASE NOTE: This can damage your cache, by changing the times it"
59 echo "sends to the remote server to see if the file was modified."
60 echo "I recommend just touching the file, then rerunning this script to"
61 echo "wipe the cache clean and start over."