xref: /original-bsd/etc/daily (revision e0c0d005)
1#!/bin/sh -
2#
3#	@(#)daily	5.11 (Berkeley) 09/17/90
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 {} \; >/dev/null 2>&1; }
16fi
17
18if [ -d /var/tmp ]; then
19	cd /var/tmp && {
20	find .	! -name . -atime +7 -exec rm -f {} \;
21	find .	! -name . -type d -mtime +1 -exec rmdir {} \; >/dev/null 2>&1; }
22fi
23
24if [ -d /scratch ]; then
25	cd /scratch && {
26	find .	! -name . -atime +1 -exec rm -f {} \;
27	find .	! -name . -type d -mtime +1 -exec rmdir {} \; >/dev/null 2>&1; }
28fi
29
30if [ -d /var/preserve ]; then
31	cd /var/preserve && {
32	find .	! -name . -mtime +7 -exec rm -f {} \; ; }
33fi
34
35if [ -d /var/rwho ] ; then
36	cd /var/rwho && {
37	find .	! -name . -mtime +7 -exec rm -f {} \; ; }
38fi
39
40cd /tmp
41find /  ! -fstype local -a -prune -o \
42	\( -name '[#,]*' -o -name '.#*' -o -name a.out -o -name core \
43	   -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \
44		-a -atime +3 -exec rm -f {} \;
45msgs -c
46if [ -f /etc/news.expire ]; then
47	/etc/news.expire
48fi
49
50echo ""
51echo "Purging accounting records:"
52mv /var/account/acct.2 /var/account/acct.3
53mv /var/account/acct.1 /var/account/acct.2
54mv /var/account/acct.0 /var/account/acct.1
55cp /var/account/acct /var/account/acct.0
56sa -s > /dev/null
57
58echo ""
59echo "Backup passwd and group files:"
60if cmp -s $bak/master.passwd.bak /etc/master.passwd; then :; else
61	echo "$host passwd diffs:"
62	diff $bak/master.passwd.bak /etc/master.passwd
63	mv $bak/master.passwd.bak $bak/master.passwd.bak2
64	cp -p /etc/master.passwd $bak/master.passwd.bak
65fi
66if cmp -s $bak/group.bak /etc/group; then :; else
67	mv $bak/group.bak $bak/group.bak2
68	cp -p /etc/group $bak/group.bak
69fi
70if cmp -s $bak/aliases.bak /etc/aliases; then :; else
71	mv $bak/aliases.bak $bak/aliases.bak2
72	cp -p /etc/aliases $bak/aliases.bak
73fi
74if [ -f /etc/Distfile ]; then
75	if cmp -s $bak/Distfile.bak /etc/Distfile; then :; else
76		mv $bak/Distfile.bak $bak/Distfile.bak2
77		cp /etc/Distfile $bak/Distfile.bak
78	fi
79fi
80
81echo ""
82echo "Running calendar:"
83calendar -a
84
85echo ""
86echo "Rotating mail log:"
87cd /var/log
88rm -f maillog.7
89if [ -f maillog.6 ]; then mv -f maillog.6  maillog.7; fi
90if [ -f maillog.5 ]; then mv -f maillog.5  maillog.6; fi
91if [ -f maillog.4 ]; then mv -f maillog.4  maillog.5; fi
92if [ -f maillog.3 ]; then mv -f maillog.3  maillog.4; fi
93if [ -f maillog.2 ]; then mv -f maillog.2  maillog.3; fi
94if [ -f maillog.1 ]; then mv -f maillog.1  maillog.2; fi
95if [ -f maillog.0 ]; then mv -f maillog.0  maillog.1; fi
96mv -f maillog maillog.0
97cp /dev/null maillog
98chmod 644    maillog
99kill -1 `cat /var/run/syslog.pid`
100cd /
101
102if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then
103	echo ""
104	echo "Cleaning up UUCP:"
105	echo /etc/uuclean.daily | su daemon
106fi
107
108echo ""
109echo ""
110echo "Checking subsystem status:"
111echo ""
112echo "disks:"
113df -k
114echo ""
115dump W
116echo ""
117
118
119echo ""
120echo "mail:"
121mailq
122
123if [ -d /var/spool/uucp ]; then
124	echo ""
125	echo "uucp:"
126	uusnap
127fi
128
129echo ""
130echo "network:"
131netstat -i
132echo ""
133ruptime
134
135echo ""
136echo "Checking filesystems:"
137fsck -n | grep -v '^\*\* Phase'
138
139echo ""
140if [ -f /etc/Distfile ]; then
141	echo "Running rdist:"
142	rdist -f /etc/Distfile
143fi
144
145sh /etc/security | mail -s "daily insecurity output" root
146