#!/bin/csh -f # # Cora, the cleaning lady -- Basic weekly cleaning # # This script performs basic system cleaning, usually done once a week. # It should be invoked by cron, or by the weekly script run by cron # (e.g. /usr/local/adm/weekly). It should be run *after* any security # checks (e.g. Walter) -- otherwise the cleanup might first destroy # evidence of a break-in or other problem. # # Eric Myers - 18 July 1996 # Department of Physics, University of Michigan, Ann Arbor # @(#) $Id: Cora,v 1.33 2008/01/28 02:04:00 myers Exp myers $ ####################################################################### # Configuration: # Set the path just to what is needed, nothing else. set path=( /usr/bin /bin /usr/ucb /usr/bsd ) set UNAME=`uname` # system type set XDEV=" -xdev " # may be " -mount" on some systems? if ( "$UNAME" == "IRIX" ) XDEV=" -mount " # general arguments for Unix find command: set FARG="" if ( -f /hp-ux ) set FARG=" -hidden " # HP-UX 9.x hidden files ###################################### ## @(#)* Clean out any old msgs if ( -x /usr/ucb/msgs ) /usr/ucb/msgs -c if ( -x /usr/local/bin/msgs ) /usr/local/bin/msgs -c ###################################### ## @(#)* Remove old files and directories from /tmp, /usr/tmp, etc... # expiration time (in days) for files in /tmp, /usr/tmp, etc. set TEMPEXP=7 set TEMPDIRS=( /tmp /var/tmp /usr/tmp /.garbage.bin /.wastebasket ) set TEMPDIRS=( $TEMPDIRS /root/.garbage.bin /var/root/.garbage.bin ) foreach DIR ( $TEMPDIRS ) if ( -d $DIR ) then find $DIR $XDEV ${FARG} -type f -atime +${TEMPEXP} -exec /bin/rm -f {} \; find $DIR $XDEV ${FARG} -depth -mindepth 1 -type d -empty -mtime +${TEMPEXP} -exec /bin/rmdir {} \; endif end ###################################### ## @(#)* Clean out any old cat'd man pages # expiration time (in days) for cat'd man pages set MANEXP=30 set MANDIRS=( /usr/man /usr/local/man /usr/local/gnu/man /usr/lang/man ) set MANDIRS=( $MANDIRS /usr/openwin/man /var/man ) set nonomatch foreach DIR ( $MANDIRS ) if ( -d $DIR ) then foreach CDIR ( ${DIR}/cat* ) if ( -d $CDIR ) then find ${CDIR} $XDEV ${FARG} -type f -atime +${MANEXP} -exec /bin/rm -f {} \; endif end endif end unset nonomatch ###################################### ## @(#)* Remove old core files everywhere find / $XDEV ${FARG} -name core -type f -mtime +5 -exec rm -f {} \; ###################################### ## @(#)* Remove old unused TeX fonts. THIS IS BROKEN # #set TEXFONTDIRS=( /var/lib/texmf /usr/share/texmf/) # #foreach DIR ( $TEXFONTDIRS ) # if ( ! -d $DIR ) continue # find $DIR $XDEV ${FARG} -type f -mtime +30 -exec rm -f {} \; #end ###################################### ## @(#)* Remove old files in user garbage/wastebasket directories, etc set HOMELIST=( /Users /home /users /usr0/home /home4 ) set TRASHLIST=( .garbage.bin tmp .wastebasket .netscape-cache .netscape/cache ) foreach HOMEROOT ( $HOMELIST ) if ( ! -d $HOMEROOT ) continue cd $HOMEROOT set USERLIST=`ls -1` foreach USERNAME ( $USERLIST ) if ( ! -d $HOMEROOT/$USERNAME ) continue cd $HOMEROOT/$USERNAME foreach TRASHDIR ( $TRASHLIST ) set DIR=$HOMEROOT/$USERNAME/$TRASHDIR/ if ( -d $DIR ) then find $DIR $XDEV ${FARG} -type f -mtime +14 -exec /bin/rm -f {} \; find $DIR $XDEV ${FARG} -depth -mindepth 1 -type d -empty -mtime +14 -exec /bin/rmdir {} \; endif end end end ###################################### ## @(#)* Remove old rwhod entries set RWHODIRS=( /var/spool/rwho /var/rwho ) set RWHOAGE=7 foreach DIR ( $RWHODIRS ) if ( ! -d $DIR ) continue cd $DIR find . $XDEV ${FARG} -type f -mtime +$RWHOAGE -exec rm -f {} \; /bin/rm -f whod.localhost whod.linux-install end ## exit 0