Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site seismo.CSS.GOV Posting-Version: version B 2.10.2 9/3/84; site panda.UUCP Path: seismo!uwvax!harvard!talcott!panda!sources-request From: sources-request@panda.UUCP Newsgroups: mod.sources Subject: sendmail clean-up script Message-ID: <1104@panda.UUCP> Date: 13 Nov 85 21:11:14 GMT Sender: jpn@panda.UUCP Lines: 82 Approved: jpn@panda.UUCP Mod.sources: Volume 3, Issue 43 Submitted by: David Barto : feed me to sh cat > INFO <<'end-INFO' The following is a script to track and mail to ADMIN the clean up of the sendmail queue. This clears invalid files, moves out the wedged mail and sends a report to the administrator listed in ADMIN. I have been using it for about 3 months without problems, and It lets me know how well the local area network moves its mail. I install it as /usr/adm/clr.queue, and have cron run it once a nite at about 2am. (low active user count). end-INFO cat > clr.queue <<'end-clr.queue' #! /bin/csh -f # clear the sendmail queue of any waiting mail # set ADMIN = barto set mqueue = /usr/spool/mqueue set output = /tmp/clr.out$$ cat /dev/null > $output cd $mqueue foreach f (*) switch ($f) case 'syslog*': # skip log files breaksw; case 'df*': set qf = `echo $f | sed -e 's/df/qf/' ` if (! -e $qf) then echo "Missing qf file for $f" >> $output echo "Contents of $f follow:" >> $output cat $f >> $output echo "---- end of $f" >> $output echo "/bin/rm -f $f" >> $output /bin/rm -f $f else if (-z $f) then echo "$f is empty, deleted" >> $output /bin/rm -f $f endif breaksw case 'xf*': case 'lf*': echo /bin/rm $f >> $output /bin/rm $f breaksw case 'qf*': set df = `echo $f | sed -e 's/qf/df/' ` if (! -e $df) then echo "Missing df file for $f" >> $output echo "Contents of $f follow:" >> $output cat $f >> $output echo "---- end of $f" >> $output echo /bin/rm $f >> $output /bin/rm $f endif breaksw default: echo "Invalid file $f, deleted" >> $output /bin/rm -f $f breaksw endsw end /usr/lib/sendmail -q -v >> $output if (! -z $output) then Mail -s "Sendmail Cleanup" $ADMIN < $output endif /bin/rm $output end-clr.queue exit