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