diff lisp/w3/clean-cache @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents
children 131b0175ea99
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/w3/clean-cache	Mon Aug 13 08:46:35 2007 +0200
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# Copyright © 1995, William M. Perry <wmperry@spry.com>
+#
+# Author:	William M. Perry <wmperry@spry.com>
+# Maintainer:	William M. Perry <wmperry@spry.com>
+# Created:	95/04/18 10:44:15
+# Version:	$Revision: 1.1.1.1 $
+# Modified:     $Date: 1996/12/18 03:46:20 $
+# Keywords:	cache clean
+# 
+# This shell script will clean out your cache directory for emacs-w3
+# It is designed to be run from a cron (see crontab(5)) or at(1)
+#
+# This should probably only be run occasionally: like once a month, or
+# when you determine that the cache size is too big.  Something like:
+#
+# CACHEMAXSIZE=5000
+# SIZE=`du -s $CACHE_ROOT | awk '{print $1}'
+# if [ $SIZE -gt 5000 ] ; then
+#   /run/the/real/clean-cache
+# fi
+
+if [ -z "$CACHE_ROOT" ] ; then
+  CACHE_ROOT=/tmp/$USER			# The root directory of the cache
+fi
+
+if [ -z "$CONTROL_FILE" ] ; then
+  CONTROL_FILE="$CACHE_ROOT/.clean"
+fi
+
+if [ -z "$CLEAN_PROTOCOLS" ] ; then
+  CLEAN_PROTOCOLS="http gopher file ftp wais news"
+fi
+
+if [ -f "$CONTROL_FILE" ] ; then
+  echo "Starting to clean $CACHE_ROOT..." `date`
+
+  for x in $CLEAN_PROTOCOLS
+  do
+    if [ -d "$x" ] ; then
+      echo "  Cleaning $x files"
+      find $CACHE_ROOT/$x -depth -type f \( ! -anewer "$CONTROL_FILE" \) \
+       -exec rm -f {} \;
+      find $CACHE_ROOT/$x -depth -type d -exec rmdir {} \;
+    fi
+  done
+  
+  touch "$CONTROL_FILE"
+  echo "Cache clean ended: "`date`
+else
+  echo "The cleaning control file ($CONTROL_FILE) could not be found."
+  echo "To create it (and make all your cache files 'current' do:"
+  echo ""
+  echo "touch $CONTROL_FILE"
+  echo "find $CACHE_ROOT -exec touch {} \;"
+  echo ""
+  echo "PLEASE NOTE: This can damage your cache, by changing the times it"
+  echo "sends to the remote server to see if the file was modified."
+  echo "I recommend just touching the file, then rerunning this script to"
+  echo "wipe the cache clean and start over."
+fi