This is the work of YouKnowWho (R.I.P), all credit to him
hello to all i made again a small contribution to this great forum
i hope that a few of you can use this script.
I made this script for me, because i run my server from a compact flash
this means that if you have to much logs, the pace can run full.
this leads to errors.
and if the log is getting to big you can't see what your looking for anymore.
its verry easy to use and easy to install
put the script in the directory where you have your scripts.
chmod the file 755
set crontab -e
01 04 * * 1 /where ever your script is/LogCleanup.sh
this means the script will remove all the log files
ones a week on monday at 4:01 AM
you have to name the files /directory's yourself and you can replace the echo text as you wish to have it.
my server restarts CCcam in debug if it has crasht and writes a debug file
in /var/cccamlog
and i have a configupdate that runs ones a night and writes a log when it has add a new peer.
and a check script that checks the CCcam every 5 min if it is still running
and it writes a log to
this way i can check if the CCcam has done his work ore has some problems.
but as i said it takes space on the HDD and that is what should be clean.
[COLOR=#ff0000]OWNER= yourusername frome the distro you use[/COLOR]
#############################################
scriptname = LogCleanup.sh
#############################################
#!/bin/sh
# Script to cleanup log files
# Script written by Youknowhoo.
OWNER=
TARGETDIR_1=/tmp
TARGETDIR_2=/var/cccamlog
FILE_1=warnings.txt
FILE_2=cccam.check
FILE_3=CCcam.log
FILE_4=configupdate.log
echo && date
if test -f $TARGETDIR_1/$FILE_1 ; then
echo "warning text present!"
chown $OWNER $TARGETDIR_1/$FILE_1
rm $TARGETDIR_1/$FILE_1
else
echo "No warning text present?!?!Nothing to remove"
fi
if test -f $TARGETDIR_2/$FILE_2 ; then
echo "Check File present!"
chown $OWNER $TARGETDIR_2/$FILE_2
rm $TARGETDIR_2/$FILE_2
else
echo "No Check File present?!?! Nothing to remove"
fi
if test -f $TARGETDIR_2/$FILE_3 ; then
echo "CCcam Debug Log precent!"
chown $OWNER $TARGETDIR_2/$FILE_3
rm $TARGETDIR_2/$FILE_3
else
echo "No! CCcam Debug log present, CCcam did run perfect !!"
fi
if test -f $TARGETDIR_2/$FILE_4 ; then
echo "Check File present!"
chown $OWNER $TARGETDIR_2/$FILE_4
rm $TARGETDIR_2/$FILE_4
else
echo "No Configupdate log present?!?! Nothing to remove"
fi
exit
Display More