#!/bin/sh #nrm.cleanup #script used by nrm(1) to cleanup erased files #keeps log file: LOGFILE and removes all components of #deleted directories that have not been changed for GRACETIME #will also delete directories as they become empty. #Rick Walker 10/10/86 NUMLINES=200 #number of lines to save in logfile LOGFILE=/etc/nrm.log #logfile for deleted filenames TEMPFILE=/tmp/nrm.$$ #tmp file used each day to list all deleted files BUGFILE=/dev/null #BUGFILE=/tmp/nrmbugs.$$ #touch $BUGFILE GRACETIME="+3" #gracetime number of days to let files hang around #if you modify this line then update the man page. #( needs a leading "+" sign ) echo '****' 'Files Deleted' `date` '****' > $TEMPFILE # HP-UX 9.0 #find / -fsonly hfs -name '.gone' -print 2>/dev/null | # Linux 2.0.18 nice find / -type d -name '.gone' -print 2>/dev/null | while read file do #kill all old files find $file ! -type d -atime $GRACETIME\ -exec /bin/rm -f {} \; \ -print \ >> $TEMPFILE 2>>$BUGFILE #kill all empty directories find $file -type d \ -exec /bin/rmdir {} \; \ -print \ >> $TEMPFILE 2>>$BUGFILE done touch $LOGFILE cat $LOGFILE >> $TEMPFILE head -$NUMLINES $TEMPFILE > $LOGFILE /bin/rm $TEMPFILE exit 0