3 # daily - daily cleanup of the system.
5 # Doesn't make sense when running from CD
6 if [ ! -z $
(sysenv bootcd
) ]
14 *) echo >&2 "Usage: $0 cron|boot"
18 test -d /usr
/adm ||
exit
21 # Last run must have been on a previous day.
22 timestamp
=daily.lasttime
25 set -- `ls -lT $timestamp`
26 test "$6 $7 $9" = "$(date '+%b %d %Y')" && exit
29 # Update last-run time
32 # Remove three day old files from various tmp dirs.
33 cleantmp
-3 /tmp
/usr
/tmp
/usr
/preserve
/usr
/spool
/lpd
/usr
/spool
/at
/past
35 # Truncate log files in /usr/adm.
36 test -d old || mkdir old ||
exit
40 # Cycle a log file if larger than a size in kilobytes.
41 local size
="`expr "$1" + "$1"`"
44 if test -f "$log" && test -n "$(find "$log" -size +"$size")"
46 test -f "old/$log.2" && cp -p "old/$log.2" "old/$log.3"
47 test -f "old/$log.1" && cp -p "old/$log.1" "old/$log.2"
48 cp -p "$log" "old/$log.1"
58 # Make copies of /etc/passwd and /etc/shadow if they have been changed.
59 for file in passwd shadow
61 if cmp -s /etc
/$file old
/$file.1
65 test -f old
/$file.2 && cp -p old
/$file.2 old
/$file.3
66 test -f old
/$file.1 && cp -p old
/$file.1 old
/$file.2
67 test -f /etc
/$file && cp -p /etc
/$file old
/$file.1
71 # Update manpage index but don't warn about nonexistant dirs
72 /usr
/libexec
/makewhatis
-f 2>/dev
/null
74 # Continue with a local script if present.
75 test -f /usr
/local
/etc
/daily
&& sh
/usr
/local
/etc
/daily
$caller