daily revision 1.24
1#!/bin/sh - 2# 3# $NetBSD: daily,v 1.24 1997/10/27 04:18:06 lukem 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 \ 123 -f /usr/libexec/uucp/clean.daily ]; then 124 echo "" 125 echo "Cleaning up UUCP:" 126 su daemon -c /usr/libexec/uucp/clean.daily 127fi 128 129if [ "$check_disks" != NO ]; then 130 df -k > $TMP 131 dump W > $TMP2 132 if [ -s $TMP -o -s $TMP2 ]; then 133 echo "" 134 echo "Checking subsystem status:" 135 echo "" 136 echo "disks:" 137 if [ -s $TMP ]; then 138 cat $TMP 139 echo "" 140 fi 141 if [ -s $TMP2 ]; then 142 cat $TMP2 143 echo "" 144 fi 145 echo "" 146 fi 147fi 148 149rm -f $TMP $TMP2 150 151if [ "$check_mailq" != NO ]; then 152 mailq > $TMP 153 if ! grep -q "^Mail queue is empty$" $TMP; then 154 echo "" 155 echo "mail:" 156 cat $TMP 157 fi 158fi 159 160rm -f $TMP 161 162if [ "$check_uucp" != NO -a -d /var/spool/uucp ]; then 163 uustat -a > $TMP 164 if [ -s $TMP ]; then 165 echo "" 166 echo "uucp:" 167 cat $TMP 168 fi 169fi 170 171rm -f $TMP 172 173if [ "$check_network" != NO ]; then 174 echo "" 175 echo "network:" 176 netstat -i 177 echo "" 178 t=/var/rwho/* 179 if [ "$t" != '/var/rwho/*' ]; then 180 ruptime 181 fi 182fi 183 184if [ "$run_fsck" != NO ]; then 185 echo "" 186 echo "Checking filesystems:" 187 fsck -n | grep -v '^\*\* Phase' 188fi 189 190echo "" 191if [ "$run_rdist" != NO -a -f /etc/Distfile ]; then 192 echo "Running rdist:" 193 if [ -d /var/log/rdist ]; then 194 logf=`date +%Y.%b.%e` 195 rdist -f /etc/Distfile 2>&1 | tee /var/log/rdist/$logf 196 else 197 rdist -f /etc/Distfile 198 fi 199fi 200 201if [ "$run_security" != NO ]; then 202 sh /etc/security 2>&1 | mail -s "$host daily insecurity output" $MAILTO 203fi 204 205rm -rf $TMPDIR 206