Randy McMurchy wrote:

The floor is now open for discussion about which packages folks use,
or if you use a home-brewed script, please contribute. If we're going
to add a package to BLFS, it may as well be the best/most favorite/you
pick the adjective/ package.
I have no use for anything even a day old. My builds hardly last a week! Attached an old version of cleanup. If I had time to setup fcron, I'd update it. All logs aren't in this script.

--
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.
LINES=75       # Default 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;
}


tail -$LINES sys.log > mesg.temp # Saves last section of message log file.
mv mesg.temp sys.log             # Becomes new log directory.

tail -$LINES user.log > mesg.temp
mv mesg.temp user.log

tail -$LINES daemon.log > mesg.temp
mv mesg.temp daemon.log

tail -$LINES scrollkeeper.log > mesg.temp
mv mesg.temp scrollkeeper.log

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