500.daily   [plain text]


#!/bin/sh -
#
#	@(#)daily	8.2 (Berkeley) 1/25/94
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
host=`hostname -s`
bak=/var/backups

echo ""
echo "Removing scratch and junk files:"

if [ -d /var/rwho ] ; then
    cd /var/rwho && {
    find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
fi

# Clean up junk files.
#find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
#       \( -name '[#,]*' -o -name '.#*' -o -name a.out -o -name '*.core' \
#	  -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
#	       -a -atime +3 -exec rm -f -- {} \;

# Clean up NFS turds.  May be useful on NFS servers.
#if [ "${host}" != "localhost" ]; then
#    find / -name .nfs\* -mtime +7 -exec rm -f -- {} \; -o -fstype nfs -prune
#fi

if [ -d /var/spool/fax ]; then
    echo ""
    echo "Removing scratch fax files"
    cd /var/spool/fax && \
    find . -type f -name '[0-9]*.[0-9][0-9][0-9]' -mtime +7 -delete >/dev/null 2>&1;
fi

if [ -f /var/account/acct ] ; then
    if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
    echo ""
    echo "Gathering accounting statistics:"
    cd /var/account
    if [ -f "acct.2${gzext}" ] ; then mv -f "acct.2${gzext}" "acct.3${gzext}" ; fi
    if [ -f "acct.1${gzext}" ] ; then mv -f "acct.1${gzext}" "acct.2${gzext}" ; fi
    if [ -f "acct.0${gzext}" ] ; then mv -f "acct.0${gzext}" "acct.1${gzext}" ; fi
    cp -pf acct acct.0
    if [ -x /usr/bin/gzip ]; then gzip -9 acct.0; fi
    sa -s > /dev/null
fi

echo ""
echo "Checking subsystem status:"

echo ""
echo "disks:"
df -k -l
echo ""
dump W

echo ""
echo "network:"
netstat -i

if [ -f /etc/daily.local ]; then
    echo ""
    echo "Running daily.local:"
    sh /etc/daily.local
fi

if [ -f /etc/security ]; then
    echo ""
    echo "Running security:"
    sh /etc/security 2>&1 | sendmail root
fi