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