#!/bin/sh -
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
host=`hostname`
echo "Subject: $host daily run output"
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
if [ -d /tmp ]; then
cd /tmp && {
find . -fstype local -type f -atime +3 -ctime +3 -exec rm -f -- {} \;
find -fstype local -d . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
>/dev/null 2>&1; }
fi
if [ -d /var/tmp ]; then
cd /var/tmp && {
find . -fstype local ! -name . -atime +7 -ctime +3 -exec rm -f -- {} \;
find -fstype local -d . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
>/dev/null 2>&1; }
fi
msgs -c
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
if [ -d /var/db/netinfo ]; then
echo ""
echo "Backing up NetInfo data"
cd /var/db/netinfo
for domain in *.nidb; do
domain=$(basename $domain .nidb)
nidump -r / -t localhost/$domain > $bak/$domain.nidump;
done
fi
echo ""
echo "Checking subsystem status:"
echo ""
echo "disks:"
df -k -t local
echo ""
dump W
if [ -d /var/spool/mqueue ]; then
echo ""
echo "mail:"
mailq
fi
echo ""
echo "network:"
netstat -i
echo ""
if [ -d /var/rwho ] ; then
ruptime
fi
echo ""
echo -n "Rotating log files:"
cd /var/log
for i in system.log; do
if [ -f "${i}" ]; then
echo -n " ${i}"
if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
if [ -f "${i}" ]; then mv -f "${i}" "${i}.0" && if [ -x /usr/bin/gzip ]; then gzip -9 "${i}.0"; fi; fi
touch "${i}" && chmod 640 "${i}"
fi
done
if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat /var/run/syslog.pid | head -1); fi
echo ""
if [ -d /var/log/httpd ]; then
echo ""
echo -n "Cleaning web server log files:"
cd /var/log/httpd && \
find . -type f -name '*_log.*' -mtime +7 -exec rm -f -- {} \; >/dev/null 2>&1;
fi
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