[WBEL-users] tmpwatch command

Pierre-Francois Honore pfhonore@cea.fr
Wed, 15 Sep 2004 23:51:41 +0200


On Wed, 2004-09-15 at 19:35, Jason Becker wrote:
> Hi All,
> 
> My servers don't get rebooted very often but when they do I'd like /tmp 
> to be cleared out. I really like the *BSD clear_tmp_enable (in rc.conf) 
> method for doing this. Linux has tmpwatch. Would someone care to share 
> there command line for a cron job?
> 
> TIA
> 
> Cheers

On Wed, 2004-09-15 at 19:35, Jason Becker wrote: 
> Hi All,
> 
> My servers don't get rebooted very often but when they do I'd like /tmp 
> to be cleared out. I really like the *BSD clear_tmp_enable (in rc.conf) 
> method for doing this. Linux has tmpwatch. Would someone care to share 
> there command line for a cron job?
> 
> TIA
> 
> Cheers

Debian is doing this cleaning. Here is a extract of
/etc/init.d/bootmisc.sh from a Debian/Sarge GNU/Linux distribution:

----------------------------------------------------------------- 
#
# Wipe /tmp (and don't erase `lost+found', `quota.user' or `quota.group')!
# Note that files _in_ lost+found _are_ deleted.
#
[ "$VERBOSE" != no ] && echo -n "Cleaning: /tmp "
#
#	If $TMPTIME is set to 0, we do not use any ctime expression
#	at all, so we can also delete files with timestamps
#	in the future!
#
if [ "$TMPTIME" = 0 ]
then
	TEXPR=""
else
	TEXPR="! -ctime -$TMPTIME"
fi
( cd /tmp && \
  find . -xdev \
  $TEXPR \
  ! -name . \
  ! \( -name lost+found -uid 0 \) \
  ! \( -name quota.user -uid 0 \) \
  ! \( -name quota.group -uid 0 \) \
    -depth -exec rm -rf -- {} \; )
rm -f /tmp/.X*-lock
#
# Clean up any stale locks.
#
[ "$VERBOSE" != no ] && echo -n "/var/lock "
( cd /var/lock && find . -type f ! -newer /etc/mtab -exec rm -f -- {} \; )

[ "$VERBOSE" != no ] && echo "."
---------------------------------------------------------

-- 

Pierre-Francois Honore <pfhonore@cea.fr>