daily revision 1.4
1#!/bin/sh -
2#
3#	$OpenBSD: daily,v 1.4 1996/05/26 10:25:20 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:"
17if [ -d /tmp -a ! -h /tmp ]; then
18	cd /tmp && {
19	find . -type f -atime +3 -exec rm -f -- {} \;
20	find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
21	    >/dev/null 2>&1; }
22fi
23
24if [ -d /var/tmp -a ! -h /var/tmp ]; then
25	cd /var/tmp && {
26	find . ! -name . -atime +7 -exec rm -f -- {} \;
27	find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
28	    >/dev/null 2>&1; }
29fi
30
31# Additional junk directory cleanup would go like this:
32#if [ -d /scratch -a ! -h /scratch ]; then
33#	cd /scratch && {
34#	find . ! -name . -atime +1 -exec rm -f -- {} \;
35#	find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
36#	    >/dev/null 2>&1; }
37#fi
38
39if [ -d /var/rwho -a ! -h /var/rwho ] ; then
40	cd /var/rwho && {
41	find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
42fi
43
44cd /tmp
45TMP=daily.$$
46find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \
47		-o -fstype kernfs -o -fstype procfs \) -a -prune -o \
48	-name 'lost+found' -a -prune -o \
49	-name '*.core' -a -print -o \
50	\( -name '[#,]*' -o -name '.#*' -o -name a.out \
51	   -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
52		-a -atime +3 -exec rm -f -- {} \; -a -print > $TMP
53
54echo ""
55echo "Possible core dumps:"
56egrep '\.core' $TMP
57
58echo ""
59echo "Deleted files:"
60egrep -v '\.core' $TMP
61
62rm -f $TMP
63
64msgs -c
65
66if [ -f /etc/news.expire ]; then
67	/etc/news.expire
68fi
69
70if [ -f /var/account/acct ]; then
71	echo "" ;
72	echo "Purging accounting records:" ;
73	mv /var/account/acct.2 /var/account/acct.3 ;
74	mv /var/account/acct.1 /var/account/acct.2 ;
75	mv /var/account/acct.0 /var/account/acct.1 ;
76	cp /var/account/acct /var/account/acct.0 ;
77	sa -sq ;
78fi
79
80echo ""
81echo "Running calendar:"
82calendar -a
83
84# Rotation of mail log now handled automatically by cron and 'newsyslog'
85
86if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
87	echo ""
88	echo "Cleaning up UUCP:"
89	echo /etc/uuclean.daily | su daemon
90fi
91
92echo ""
93echo ""
94echo "Checking subsystem status:"
95echo ""
96echo "disks:"
97df -k
98echo ""
99dump W
100echo ""
101
102
103echo ""
104echo "mail:"
105mailq
106
107if [ -d /var/spool/uucp ]; then
108	echo ""
109	echo "uucp:"
110	uustat -a
111fi
112
113echo ""
114echo "network:"
115netstat -i
116echo ""
117ruptime
118
119echo ""
120echo "Checking filesystems:"
121fsck -n | grep -v '^\*\* Phase'
122
123echo ""
124if [ -f /etc/Distfile ]; then
125	echo "Running rdist:"
126	rdist -f /etc/Distfile
127fi
128
129sh /etc/security 2>&1 | mail -s "daily insecurity output" root
130