daily revision 1.6
1#!/bin/sh - 2# 3# $OpenBSD: daily,v 1.6 1996/06/17 09:09:39 deraadt Exp $ 4# 5PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local 6host=`hostname -s` 7echo "Subject: $host daily run output" 8 9if [ -f /etc/daily.local ];then 10 echo "" 11 echo "Running daily.local:" 12 . /etc/daily.local 13fi 14 15echo "" 16echo "Removing scratch and junk files:" 17# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED" 18#if [ -d /tmp -a ! -h /tmp ]; then 19# cd /tmp && { 20# find . -type f -atime +3 -exec rm -f -- {} \; 21# find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ 22# >/dev/null 2>&1; } 23#fi 24 25# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED 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# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED 44# find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } 45#fi 46 47# XXX NOT REMOVING UNTIL SECURITY BUG IS FIXED 48#cd /tmp 49#TMP=daily.$$ 50#find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ 51# -o -fstype kernfs -o -fstype procfs \) -a -prune -o \ 52# -name 'lost+found' -a -prune -o \ 53# -name '*.core' -a -print -o \ 54# \( -name '[#,]*' -o -name '.#*' -o -name a.out \ 55# -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ 56# -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP 57 58echo "" 59echo "Possible core dumps:" 60egrep '\.core' $TMP 61 62echo "" 63echo "Deleted files:" 64egrep -v '\.core' $TMP 65 66rm -f $TMP 67 68msgs -c 69 70if [ -f /etc/news.expire ]; then 71 /etc/news.expire 72fi 73 74if [ -f /var/account/acct ]; then 75 echo "" ; 76 echo "Purging accounting records:" ; 77 mv /var/account/acct.2 /var/account/acct.3 ; 78 mv /var/account/acct.1 /var/account/acct.2 ; 79 mv /var/account/acct.0 /var/account/acct.1 ; 80 cp /var/account/acct /var/account/acct.0 ; 81 sa -sq ; 82fi 83 84echo "" 85echo "Running calendar:" 86calendar -a 87 88# Rotation of mail log now handled automatically by cron and 'newsyslog' 89 90if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then 91 echo "" 92 echo "Cleaning up UUCP:" 93 echo /etc/uuclean.daily | su daemon 94fi 95 96echo "" 97echo "" 98echo "Checking subsystem status:" 99echo "" 100echo "disks:" 101df -k 102echo "" 103dump W 104echo "" 105 106 107echo "" 108echo "mail:" 109mailq 110 111if [ -d /var/spool/uucp ]; then 112 echo "" 113 echo "uucp:" 114 uustat -a 115fi 116 117echo "" 118echo "network:" 119netstat -i 120echo "" 121ruptime 122 123echo "" 124echo "Checking filesystems:" 125fsck -n | grep -v '^\*\* Phase' 126 127echo "" 128if [ -f /etc/Distfile ]; then 129 echo "Running rdist:" 130 rdist -f /etc/Distfile 131fi 132 133sh /etc/security 2>&1 | mail -s "daily insecurity output" root 134