David Jensen wrote:

Attached an old version of cleanup. If I had time to setup fcron, I'd update it. All logs aren't in this script.

I cleaned it up. Note: I exclude kern messages from sys.log, so it is quite small. I don't know why the LFS syslog.conf default has the kern messages double logged.

What is to be done with the boot.log, it supposedly logs the bootscripts. I am waiting for my first message.

I just know my script will get first prize! :-)
--
David Jensen


#!/bin/bash
# cleanup, version 2
# Run as root, of course.

LOG_DIR=/var/log
ROOT_UID=0     # Only users with $UID 0 have root privileges.
DEF_LINES=50   # Default number of lines saved.
KERN_LINES=200 # Kernel log number of lines saved.
E_XCD=66       # Can't change directory?
E_NOTROOT=67   # Non-root exit error.

if [ "$UID" -ne "$ROOT_UID" ]
then
  echo "Must be root to run this script."
  exit $E_NOTROOT
fi  

cd $LOG_DIR || {
  echo "Cannot change to necessary directory." >&2
  exit $E_XCD;
}

trunc_log () {
   tail -$1 $2 > mesg.temp            # Saves last section of message log file.
   mv mesg.temp $2                    # Becomes new log.
}

trunc_log $KERN_LINES kern.log       # Special case, more lines saved
for name in {sys,auth,daemon,user,scrollkeeper} ; do
   trunc_log $DEF_LINES $name.log
done

cat /dev/null > wtmp
cat /dev/null > btmp
cat /dev/null > lastlog

echo "Logs cleaned up."

exit 0

-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to