1 #!/bin/sh - 2 # 3 # $NetBSD: daily,v 1.18 1997/01/05 11:21:09 mrg Exp $ 4 # 5 # form: @(#)daily 5.12 (Berkeley) 5/24/91 6 # 7 8 PATH=/bin:/usr/bin:/sbin:/usr/sbin 9 host=`hostname -s` 10 echo "Subject: $host daily run output" 11 12 umask 077 13 14 if [ -s /etc/daily.conf ]; then 15 . /etc/daily.conf 16 fi 17 18 #echo "" 19 #echo "Removing scratch and junk files:" 20 #if [ -d /tmp -a ! -h /tmp ]; then 21 # cd /tmp && { 22 # find . -type f -atime +3 -exec rm -f -- {} \; 23 # find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 24 # >/dev/null 2>&1; } 25 #fi 26 27 #if [ -d /var/tmp -a ! -h /var/tmp ]; then 28 # cd /var/tmp && { 29 # find . ! -name . -atime +7 -exec rm -f -- {} \; 30 # find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 31 # >/dev/null 2>&1; } 32 #fi 33 34 # Additional junk directory cleanup would go like this: 35 #if [ -d /scratch -a ! -h /scratch ]; then 36 # cd /scratch && { 37 # find . ! -name . -atime +1 -exec rm -f -- {} \; 38 # find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 39 # >/dev/null 2>&1; } 40 #fi 41 42 #if [ -d /var/rwho -a ! -h /var/rwho ] ; then 43 # cd /var/rwho && { 44 # find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } 45 #fi 46 47 TMPDIR=/tmp/_daily.$$ 48 49 if ! mkdir $TMPDIR; then 50 echo can not create $TMPDIR. 51 exit 1 52 fi 53 54 if ! cd $TMPDIR; then 55 echo can not cd to $TMPDIR. 56 exit 1 57 fi 58 59 TMP=daily.$$ 60 TMP2=daily2.$$ 61 62 if [ x"$find_core" != xNO ] ; then 63 find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ 64 -o -fstype kernfs -o -fstype procfs \) -a -prune -o \ 65 -name 'lost+found' -a -prune -o \ 66 -name '*.core' -a -print > $TMP 67 # \( -name '[#,]*' -o -name '.#*' -o -name a.out \ 68 # -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ 69 # -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP 70 71 egrep '\.core' $TMP > $TMP2 72 if [ -s $TMP2 ]; then 73 echo "" 74 echo "Possible core dumps:" 75 cat $TMP2 76 fi 77 78 # egrep -v '\.core' $TMP > $TMP2 79 # if [ -s $TMP2 ]; then 80 # echo "" 81 # echo "Deleted files:" 82 # cat $TMP2 83 # fi 84 85 rm -f $TMP $TMP2 86 fi 87 88 if [ x"$run_msgs" != xNO ]; then 89 msgs -c 90 fi 91 92 if [ x"$expire_news" != xNO -a -f /etc/news.expire ]; then 93 /etc/news.expire 94 fi 95 96 if [ x"$purge_accounting" != xNO -a -f /var/account/acct ]; then 97 echo "" ; 98 echo "Purging accounting records:" ; 99 mv /var/account/acct.2 /var/account/acct.3 ; 100 mv /var/account/acct.1 /var/account/acct.2 ; 101 mv /var/account/acct.0 /var/account/acct.1 ; 102 cp /var/account/acct /var/account/acct.0 ; 103 sa -sq ; 104 fi 105 106 if [ x"$run_calendar" != xNO ]; then 107 calendar -a > $TMP 108 if [ -s $TMP ]; then 109 echo "" 110 echo "Running calendar:" 111 cat $TMP 112 fi 113 rm -f $TMP 114 fi 115 116 if [ x"$check_uucp" != xNO -a -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then 117 echo "" 118 echo "Cleaning up UUCP:" 119 echo /etc/uuclean.daily | su daemon 120 fi 121 122 if [ x"$check_disks" != xNO ]; then 123 df -k > $TMP 124 dump W > $TMP2 125 if [ -s $TMP -o -s $TMP2 ]; then 126 echo "" 127 echo "Checking subsystem status:" 128 echo "" 129 echo "disks:" 130 if [ -s $TMP ]; then 131 cat $TMP 132 echo "" 133 fi 134 if [ -s $TMP2 ]; then 135 cat $TMP2 136 echo "" 137 fi 138 echo "" 139 fi 140 fi 141 142 rm -f $TMP $TMP2 143 144 if [ x"$check_mailq" != xNO ]; then 145 mailq > $TMP 146 if ! grep -q "^Mail queue is empty$" $TMP; then 147 echo "" 148 echo "mail:" 149 cat $TMP 150 fi 151 fi 152 153 rm -f $TMP 154 155 if [ x"$check_uucp" != xNO -a -d /var/spool/uucp ]; then 156 uustat -a > $TMP 157 if [ -s $TMP ]; then 158 echo "" 159 echo "uucp:" 160 fi 161 fi 162 163 rm -f $TMP 164 165 if [ x"$check_network" != xNO ]; then 166 echo "" 167 echo "network:" 168 netstat -i 169 echo "" 170 t=/var/rwho/* 171 if [ "$t" != '/var/rwho/*' ]; then 172 ruptime 173 fi 174 fi 175 176 if [ x"$run_fsck" != xNO ]; then 177 echo "" 178 echo "Checking filesystems:" 179 fsck -n | grep -v '^\*\* Phase' 180 fi 181 182 echo "" 183 if [ x"$run_rdist" != xNO -a -f /etc/Distfile ]; then 184 echo "Running rdist:" 185 rdist -f /etc/Distfile 186 fi 187 188 if [ x"$run_security" != xNO ]; then 189 sh /etc/security 2>&1 | mail -s "daily insecurity output" root 190 fi 191 192 rm -rf $TMPDIR 193 194 exit 195