COME ON, LEARN TOGETHER THROUGH THIS BLOG

Friday, May 20, 2011

SCRIPT TO CLEAN UP COREFILES

SCRIPT TO CLEAN UP COREFILES
Create a file called rmcores(the author calls it handle−cores) with the following in it:

#!/bin/sh
USAGE="$0 <directory> <message−file>"
if [ $# != 2 ] ; then
echo $USAGE
exit
fi

echo Deleting...
find $1 −name core −atime 7 −print −type f −exec rm {} \;
echo e−mailing
for name in `find $1 −name core −exec ls −l {} \; | cut −c16−24`
do
echo $name
cat $2 | mail $name
done

And have a cron job run it every so often.

No comments:

Post a Comment