[Linux-aus] Re: linux.conf.au

Matt Palmer mpalmer at hezmatt.org
Wed Dec 7 06:54:02 UTC 2005


On Tue, Dec 06, 2005 at 08:20:55PM +1030, David Lloyd wrote:
> 
> Hmmm...
> 
> > /tmp filled up on umlhost, and on inspection, there were a number of
> > large deleted files being help open in /tmp by the UML processes. I
> > figured a reboot would cause these files to be closed, and thus
> > properly removed from disk.
> 
> Time for a DSL uberkludge:
> 
> ---
> root# crontab -l
> 0 * * * * rm -rf /tmp/*
> ---

Oh dear ghod.  At the very least, something like:

find . -mmin +240 -exec rm -f '{}' \;

Or use one of the pre-existing tools to do this, like tmpreaper.

> Mind you stupid MySQL might go for a wander and other mentally retarded
> things that expect things in TEMPORARY directories to, ummmm, persist...
> 
> I tend to treat /tmp as a place where I can just go "rm -rf *" without
> affecting things too drastically.

Uhm, right.  If I can't rely on that data being there for *any* length of
time, what's the point of using /tmp at all?  Say I've got this script:

-----8<-----
WORKDIR=$(mktemp -d)

cp x y z ${WORKDIR}

pushd ${WORKDIR}

tar czf archive.tgz *

popd

cp ${WORKDIR}/archive.tgz .

rm -rf ${WORKDIR}
----->8-----

Sooner or later, that's going to fall foul of an "rm -rf /tmp/*".  Why?  It
seems like a reasonable use for a temporary directory -- I need it
*temporarily*.  Temporarily does not mean "Feel free to rip my feet out from
underneath me", it means "not permanently".

- Matt




More information about the linux-aus mailing list