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