# @(#)daily 5.19 (Berkeley) %G%
PATH
=/bin
:/usr
/bin
:/sbin
:/usr
/sbin
:/usr
/local
/bin
echo "Subject: $host daily run output"
echo "Removing scratch and junk files:"
find .
-type f
-atime +3 -exec rm -f -- {} \
;
find .
! -name .
-type d
-mtime +1 -exec rmdir -- {} \
; \
if [ -d /var
/tmp
-a "X$CLEANVARTMP" = X1
]; then
find .
! -name .
-atime +7 -exec rm -f -- {} \
;
find .
! -name .
-type d
-mtime +1 -exec rmdir -- {} \
; \
find .
! -name .
-atime +1 -exec rm -f -- {} \
;
find .
! -name .
-type d
-mtime +1 -exec rmdir -- {} \
; \
if [ -d /var
/preserve
]; then
find .
! -name .
-mtime +7 -exec rm -f -- {} \
; ; }
if [ -d /var
/rwho
] ; then
find .
! -name .
-mtime +7 -exec rm -f -- {} \
; ; }
find / \
( ! -fstype local -o -fstype rdonly \
) -a -prune -o \
-name 'core.*' -a -print -o \
\
( -name '[#,]*' -o -name '.#*' -o -name a.out \
-o -name '*.CKP' -o -name '.emacs_[0-9]*' \
) \
-a -atime +3 -a -exec rm -f -- {} \
; -a -print > $TMP
echo "Possible core dumps:"
egrep 'core\.' $TMP |
sed '/core.[05cho]$/d'
if [ -f /etc
/news.expire
]; then
echo "Purging accounting records:"
mv /var
/account
/acct
.2 /var
/account
/acct
.3
mv /var
/account
/acct
.1 /var
/account
/acct
.2
mv /var
/account
/acct
.0 /var
/account
/acct
.1
cp /var
/account
/acct
/var
/account
/acct
.0
# If ROOTBACKUP is set to 1 in the environment, and
# if filesystem named /altroot is type ufs, on /dev/* and mounted "xx",
# use it as a backup root filesystem to be updated daily.
[ "X$ROOTBACKUP" = X1
] && {
rootdev
=`awk '$2 == "/" && $1 ~ /^\/dev\// && $3 == "ufs" && \
{ print substr($1, 6) }' < /etc/fstab`
rootbak
=`awk '$2 == "/altroot" && $1 ~ /^\/dev\// && $3 == "ufs" && \
{ print substr($1, 6) }' < /etc/fstab`
[ X
$rootdev != X
-a X
$rootbak != X
] && {
echo "Backing up root filesystem:"
echo "copying /dev/r$rootdev to /dev/r$rootbak"
dd if=/dev
/r
$rootdev of
=/dev
/r
$rootbak bs
=16b seek
=1 skip
=1 \
echo "Rotating mail log:"
if [ -f maillog
.6 ]; then mv -f maillog
.6 maillog
.7; fi
if [ -f maillog
.5 ]; then mv -f maillog
.5 maillog
.6; fi
if [ -f maillog
.4 ]; then mv -f maillog
.4 maillog
.5; fi
if [ -f maillog
.3 ]; then mv -f maillog
.3 maillog
.4; fi
if [ -f maillog
.2 ]; then mv -f maillog
.2 maillog
.3; fi
if [ -f maillog
.1 ]; then mv -f maillog
.1 maillog
.2; fi
if [ -f maillog
.0 ]; then mv -f maillog
.0 maillog
.1; fi
kill -1 `cat /var/run/syslog.pid`
if [ -d /var
/spool
/uucp -a -f /etc
/uuclean.daily
]; then
echo /etc
/uuclean.daily | su daemon
echo "Checking subsystem status:"
if [ -d /var
/spool
/uucp ]; then
echo "Checking filesystems:"
fsck
-n |
grep -v '^\*\* Phase'
if [ -f /etc
/Distfile
]; then
if [ -d /var
/log
/rdist
]; then
logf
=`date | awk '{printf "%s.%s.%s", $6, $2, $3}'`
rdist
-f /etc
/Distfile
2>&1 |
tee /var
/log
/rdist
/$logf
sh
/etc
/security
2>&1 |
mail -s "$host daily insecurity output" root