home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / w3 / clean-cache < prev    next >
Encoding:
Text File  |  1995-04-26  |  1.8 KB  |  63 lines

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