daily revision 1.11
1#!/bin/sh - 2# 3# @(#)daily 5.12 (Berkeley) 5/24/91 4# 5PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local 6host=`hostname -s` 7echo "Subject: $host daily run output" 8bak=/var/backups 9 10echo "" 11echo "Removing scratch and junk files:" 12if [ -d /tmp -a ! -h /tmp ]; then 13 cd /tmp && { 14 find . -type f -atime +3 -exec rm -f -- {} \; 15 find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 16 >/dev/null 2>&1; } 17fi 18 19if [ -d /var/tmp -a ! -h /var/tmp ]; then 20 cd /var/tmp && { 21 find . ! -name . -atime +7 -exec rm -f -- {} \; 22 find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 23 >/dev/null 2>&1; } 24fi 25 26if [ -d /scratch -a ! -h /scratch ]; then 27 cd /scratch && { 28 find . ! -name . -atime +1 -exec rm -f -- {} \; 29 find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 30 >/dev/null 2>&1; } 31fi 32 33# XXX should go away/be replaced by nvi version 34if [ -d /var/preserve -a ! -h /var/preserve ]; then 35 cd /var/preserve && { 36 find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } 37fi 38 39if [ -d /var/rwho -a ! -h /var/rwho ] ; then 40 cd /var/rwho && { 41 find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } 42fi 43 44cd /tmp 45TMP=daily.$$ 46find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ 47 -o -fstype kernfs \) -a -prune -o \ 48 -name 'lost+found' -a -prune -o \ 49 -name '*.core' -a -print -o \ 50 \( -name '[#,]*' -o -name '.#*' -o -name a.out \ 51 -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ 52 -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP 53 54echo "" 55echo "Possible core dumps:" 56egrep '\.core' $TMP 57 58echo "" 59echo "Deleted files:" 60egrep -v '\.core' $TMP 61 62rm -f $TMP 63 64msgs -c 65 66if [ -f /etc/news.expire ]; then 67 /etc/news.expire 68fi 69 70#if [ -f /var/account ]; then 71# echo "" ; 72# echo "Purging accounting records:" ; 73# mv /var/account/acct.2 /var/account/acct.3 ; 74# mv /var/account/acct.1 /var/account/acct.2 ; 75# mv /var/account/acct.0 /var/account/acct.1 ; 76# cp /var/account/acct /var/account/acct.0 ; 77# sa -s > /dev/null ; 78#fi 79 80echo "" 81echo "Backup passwd and group files:" 82if cmp -s $bak/master.passwd.bak /etc/master.passwd; then :; else 83 echo "$host passwd diffs:" 84 diff $bak/master.passwd.bak /etc/master.passwd 85 mv $bak/master.passwd.bak $bak/master.passwd.bak2 86 cp -p /etc/master.passwd $bak/master.passwd.bak 87fi 88if cmp -s $bak/group.bak /etc/group; then :; else 89 mv $bak/group.bak $bak/group.bak2 90 cp -p /etc/group $bak/group.bak 91fi 92if cmp -s $bak/aliases.bak /etc/aliases; then :; else 93 mv $bak/aliases.bak $bak/aliases.bak2 94 cp -p /etc/aliases $bak/aliases.bak 95fi 96if [ -f /etc/Distfile ]; then 97 if cmp -s $bak/Distfile.bak /etc/Distfile; then :; else 98 mv $bak/Distfile.bak $bak/Distfile.bak2 99 cp /etc/Distfile $bak/Distfile.bak 100 fi 101fi 102 103echo "" 104echo "Running calendar:" 105calendar -a 106 107# Rotation of mail log now handled automatically by cron and 'newsyslog' 108 109if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then 110 echo "" 111 echo "Cleaning up UUCP:" 112 echo /etc/uuclean.daily | su daemon 113fi 114 115echo "" 116echo "" 117echo "Checking subsystem status:" 118echo "" 119echo "disks:" 120df -k 121echo "" 122dump W 123echo "" 124 125 126echo "" 127echo "mail:" 128mailq 129 130if [ -d /var/spool/uucp ]; then 131 echo "" 132 echo "uucp:" 133 uustat -a 134fi 135 136echo "" 137echo "network:" 138netstat -i 139echo "" 140ruptime 141 142echo "" 143echo "Checking filesystems:" 144fsck -n | grep -v '^\*\* Phase' 145 146echo "" 147if [ -f /etc/Distfile ]; then 148 echo "Running rdist:" 149 rdist -f /etc/Distfile 150fi 151 152sh /etc/security 2>&1 | mail -s "daily insecurity output" root 153