daily revision 1.8
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 ]; 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 ]; 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 ]; 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
33if [ -d /var/preserve ]; then
34	cd /var/preserve && {
35	find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
36fi
37
38if [ -d /var/rwho ] ; then
39	cd /var/rwho && {
40	find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
41fi
42
43cd /tmp
44find / \( ! -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
49if [ -f /etc/news.expire ]; then
50	/etc/news.expire
51fi
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
66echo ""
67echo "Backup passwd and group files:"
68if 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
73fi
74if 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
77fi
78if 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
81fi
82if [ -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
87fi
88
89echo ""
90echo "Running calendar:"
91calendar -a
92
93# Rotation of mail log now handled automatically by cron and 'newsyslog'
94
95if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
96	echo ""
97	echo "Cleaning up UUCP:"
98	echo /etc/uuclean.daily | su daemon
99fi
100
101echo ""
102echo ""
103echo "Checking subsystem status:"
104echo ""
105echo "disks:"
106df -k
107echo ""
108dump W
109echo ""
110
111
112echo ""
113echo "mail:"
114mailq
115
116if [ -d /var/spool/uucp ]; then
117	echo ""
118	echo "uucp:"
119	uustat -a
120fi
121
122echo ""
123echo "network:"
124netstat -i
125echo ""
126ruptime
127
128echo ""
129echo "Checking filesystems:"
130fsck -n | grep -v '^\*\* Phase'
131
132echo ""
133if [ -f /etc/Distfile ]; then
134	echo "Running rdist:"
135	rdist -f /etc/Distfile
136fi
137
138sh /etc/security 2>&1 | mail -s "daily insecurity output" root
139