NetBSD/etc/monthly

43 lines
948 B
Bash

#!/bin/sh -
#
# @(#)monthly 5.5 (Berkeley) 6/17/91
#
host=`hostname -s`
echo "Subject: $host monthly run output"
# echo ""
# echo "Doing login accounting:"
# ac -p | sort -nr +1
echo ""
echo -n "Rotating log files:"
cd /var/log
for i in kerberos.log lpd-errs wtmp aculog; do
echo -n " $i"
if [ -f $i.5.Z ]; then mv -f $i.5.Z $i.6.Z; fi
if [ -f $i.4.Z ]; then mv -f $i.4.Z $i.5.Z; fi
if [ -f $i.3.Z ]; then mv -f $i.3.Z $i.4.Z; fi
if [ -f $i.2.Z ]; then mv -f $i.2.Z $i.3.Z; fi
if [ -f $i.1.Z ]; then mv -f $i.1.Z $i.2.Z; fi
if [ -f $i.0.Z ]; then mv -f $i.0.Z $i.1.Z; fi
mv -f $i $i.0
compress -f $i.0
cp /dev/null $i
chmod 640 $i
done
echo "."
echo ""
echo "Rotating cron log:"
cd /var/cron
rm -f log.3.Z
if [ -f log.2.Z ]; then mv -f log.2.Z log.3.Z; fi
if [ -f log.1.Z ]; then mv -f log.1.Z log.2.Z; fi
if [ -f log.0.Z ]; then mv -f log.0.Z log.1.Z; fi
mv -f log log.0
compress -f log.0
cp /dev/null log
chmod 600 log
echo "."