daily revision 1.10
1#!/bin/sh -
2#
3#	@(#)daily	5.12 (Berkeley) 5/24/91
4#
5PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local
6host=`hostname -s`
7echo "Subject: $host daily run output"
8bak=/var/backups
9
10echo ""
11echo "Removing scratch and junk files:"
12if [ -d /tmp -a ! -h /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; }
17fi
18
19if [ -d /var/tmp -a ! -h /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; }
24fi
25
26if [ -d /scratch -a ! -h /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; }
31fi
32
33# XXX should go away/be replaced by nvi version
34if [ -d /var/preserve -a ! -h /var/preserve ]; then
35	cd /var/preserve && {
36	find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
37fi
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 \) -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
62msgs -c
63
64if [ -f /etc/news.expire ]; then
65	/etc/news.expire
66fi
67
68#if [ -f /var/account ]; then
69#	echo "" ;
70#	echo "Purging accounting records:" ;
71#	mv /var/account/acct.2 /var/account/acct.3 ;
72#	mv /var/account/acct.1 /var/account/acct.2 ;
73#	mv /var/account/acct.0 /var/account/acct.1 ;
74#	cp /var/account/acct /var/account/acct.0 ;
75#	sa -s > /dev/null ;
76#fi
77
78echo ""
79echo "Backup passwd and group files:"
80if cmp -s $bak/master.passwd.bak /etc/master.passwd; then :; else
81	echo "$host passwd diffs:"
82	diff $bak/master.passwd.bak /etc/master.passwd
83	mv $bak/master.passwd.bak $bak/master.passwd.bak2
84	cp -p /etc/master.passwd $bak/master.passwd.bak
85fi
86if cmp -s $bak/group.bak /etc/group; then :; else
87	mv $bak/group.bak $bak/group.bak2
88	cp -p /etc/group $bak/group.bak
89fi
90if cmp -s $bak/aliases.bak /etc/aliases; then :; else
91	mv $bak/aliases.bak $bak/aliases.bak2
92	cp -p /etc/aliases $bak/aliases.bak
93fi
94if [ -f /etc/Distfile ]; then
95	if cmp -s $bak/Distfile.bak /etc/Distfile; then :; else
96		mv $bak/Distfile.bak $bak/Distfile.bak2
97		cp /etc/Distfile $bak/Distfile.bak
98	fi
99fi
100
101echo ""
102echo "Running calendar:"
103calendar -a
104
105# Rotation of mail log now handled automatically by cron and 'newsyslog'
106
107if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
108	echo ""
109	echo "Cleaning up UUCP:"
110	echo /etc/uuclean.daily | su daemon
111fi
112
113echo ""
114echo ""
115echo "Checking subsystem status:"
116echo ""
117echo "disks:"
118df -k
119echo ""
120dump W
121echo ""
122
123
124echo ""
125echo "mail:"
126mailq
127
128if [ -d /var/spool/uucp ]; then
129	echo ""
130	echo "uucp:"
131	uustat -a
132fi
133
134echo ""
135echo "network:"
136netstat -i
137echo ""
138ruptime
139
140echo ""
141echo "Checking filesystems:"
142fsck -n | grep -v '^\*\* Phase'
143
144echo ""
145if [ -f /etc/Distfile ]; then
146	echo "Running rdist:"
147	rdist -f /etc/Distfile
148fi
149
150sh /etc/security 2>&1 | mail -s "daily insecurity output" root
151