Subject: misc/5112: let daily clean /tmp
To: None <gnats-bugs@gnats.netbsd.org>
From: Chris Jones <cjones@caesar.honors.montana.edu>
List: netbsd-bugs
Date: 03/03/1998 13:40:32
>Number: 5112
>Category: misc
>Synopsis: let daily clean /tmp
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: misc-bug-people (Misc Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Mar 4 07:05:03 1998
>Last-Modified:
>Originator: Chris Jones
>Organization:
-------------------------------------------------------------------------------
Chris Jones cjones@rupert.oscs.montana.edu
Mad scientist in training...
"Is this going to be a stand-up programming session, sir, or another bug hunt?"
>Release: <NetBSD-current source date>1.3
>Environment:
System: NetBSD caesar.honors.montana.edu 1.3 NetBSD 1.3 (CAESAR) #0: Tue Feb 10 11:29:43 MST 1998 cjones@caesar.honors.montana.edu:/usr/local/syssrc/sys/arch/i386/compile/CAESAR i386
>Description:
/etc/daily used to clean /tmp, /var/tmp, and /usr/tmp. That
functionality was commented out, however, I think because it violated
the principle of least surprise. However, this was useful
functionality.
Also, it's rather odd to have the code to do this cleaning still
sitting in /etc/daily, commented out, when we have a perfectly usable
mechanism for turning it on or off at the user's discretion, in the
form of /etc/daily.conf.
>How-To-Repeat:
>Fix:
*** daily.orig Tue Mar 3 12:43:52 1998
--- daily Tue Mar 3 13:37:02 1998
***************
*** 1,6 ****
#!/bin/sh -
#
! # $NetBSD: daily,v 1.25 1998/01/26 12:02:43 lukem Exp $
# @(#)daily 8.2 (Berkeley) 1/25/94
#
--- 1,6 ----
#!/bin/sh -
#
! # $NetBSD: $
# @(#)daily 8.2 (Berkeley) 1/25/94
#
***************
*** 29,62 ****
echo ""
echo "Uptime: " `uptime`
! #echo ""
! #echo "Removing scratch and junk files:"
! #if [ -d /tmp -a ! -h /tmp ]; then
! # cd /tmp && {
! # find . -type f -atime +3 -exec rm -f -- {} \;
! # find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
! # >/dev/null 2>&1; }
! #fi
!
! #if [ -d /var/tmp -a ! -h /var/tmp ]; then
! # cd /var/tmp && {
! # find . ! -name . -atime +7 -exec rm -f -- {} \;
! # find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
! # >/dev/null 2>&1; }
! #fi
!
! # Additional junk directory cleanup would go like this:
! #if [ -d /scratch -a ! -h /scratch ]; then
! # cd /scratch && {
! # find . ! -name . -atime +1 -exec rm -f -- {} \;
! # find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
! # >/dev/null 2>&1; }
! #fi
!
! #if [ -d /var/rwho -a ! -h /var/rwho ] ; then
! # cd /var/rwho && {
! # find . ! -name . -mtime +7 -exec rm -f -- {} \; ; }
! #fi
TMPDIR=/tmp/_daily.$$
--- 29,47 ----
echo ""
echo "Uptime: " `uptime`
! if checkyesno clean_tmp; then
! echo ""
! echo "Removing scratch and junk files:"
! ( # preserve cwd
! for I in $tmp_dirs; do
! cd $I && {
! find . ! -type d -atime +7 -exec rm -f -- {} \;
! find . ! -name . ! -name vi.recover -type d -mtime +1 \
! -exec rmdir -- {} \; 2> /dev/null
! }
! done
! )
! fi
TMPDIR=/tmp/_daily.$$
*** daily.conf.orig Tue Mar 3 12:43:52 1998
--- daily.conf Tue Mar 3 13:25:23 1998
***************
*** 1,7 ****
! # $NetBSD: daily.conf,v 1.2 1997/01/20 06:08:36 mycroft Exp $
#
# see daily.conf(5) for more information.
find_core=YES
expire_news=NO
purge_accounting=YES
--- 1,8 ----
! # $NetBSD: $
#
# see daily.conf(5) for more information.
+ clean_tmp=NO
find_core=YES
expire_news=NO
purge_accounting=YES
***************
*** 14,16 ****
--- 15,19 ----
run_fsck=NO
run_rdist=YES
run_security=YES
+
+ tmp_dirs="/tmp /var/tmp"
*** daily.conf.5.orig Tue Mar 3 12:48:18 1998
--- daily.conf.5 Tue Mar 3 13:27:41 1998
***************
*** 1,4 ****
! .\" $NetBSD: daily.conf.5,v 1.3 1997/10/10 05:39:58 mrg Exp $
.\"
.\" Copyright (c) 1996 Matthew R. Green
.\" All rights reserved.
--- 1,4 ----
! .\" $NetBSD: $
.\"
.\" Copyright (c) 1996 Matthew R. Green
.\" All rights reserved.
***************
*** 45,50 ****
--- 45,61 ----
.Pp
The variables described below can be set to "NO" to disable the test:
.Bl -tag -width purge_accounting
+ .It Sy clean_tmp
+ This says to remove old files from the temporary directories specified
+ in
+ .Sy tmp_dirs
+ (see below). If set, any files (but not directories) which have not
+ been accessed in the past 7 days will be deleted; and any directories
+ which are both empty and have not been modified in the past day will
+ be deleted.
+ .Sy NOTE:
+ This will also remove 7 day old vi recover files in
+ .Pa /var/tmp/vi.recover .
.It Sy find_core
This runs
.Xr find 1
***************
*** 101,106 ****
--- 112,126 ----
This runs the
.Pa /etc/security
script looking for possible security problems with the system.
+ .El
+ .Pp
+ The variables described below can be set to change the specifics of
+ how various jobs, specified in the previous section, run:
+ .Bl -tag -width tmp_dirs
+ .It Sy tmp_dirs
+ This specifies which temporary directories to clean, if
+ .Sy clean_tmp
+ (see above) is set.
.El
.Pp
.Sh FILES
>Audit-Trail:
>Unformatted: