/tmp/*

Seth W. Klein sk at sethwklein.net
Sat Oct 26 07:01:18 PDT 2002


"S. Bougerolle" <steveb at creek-and-cowley.com> wrote:
> 
> 
> On Sat, 2002-10-26 at 09:38, Ian Molton wrote:
> 
> > We really need to remove the contents of /tmp when we boot.
> 
> > how the HELL do you get rm to delete hidden files when you do rm -rf
> > /tmp/* ?
> 
> 1) Use TMPFS for /tmp so you don't need to worry about it.

The book can't ust tmpfs for /tmp for two reasons:
1) Many people using the book don't have enough ram+swap for that.
2) Even those who do should hesitate to use it because /tmp is the
   natural place for users to put files, even (especially?) very
   large files that they won't need after a reboot.

> 2) If that isn't practical for some reason:
> 
> find /tmp -mindepth 1 -exec rm -rf {} \;

Init scripts shouldn't use find because, on an FHS compliant system,
find is in /usr/bin. Try this (thanks to someone who posted last time
the subject came up):

for D in /tmp /var/run /var/lock; do
        for F in `ls -A $D`; do
                rm -vrf $D/$F
        done
done
touch /var/run/utmp
chmod 644 /var/run/utmp

That is cut and pasted directly from my boot scripts.

For those who object that someone might loose a file stored in /tmp
if it's cleared on boot: /var/tmp is for stuff like that. Since the
FHS recommends (mandates?) clearing /tmp on boot (i assume because
it's general practice on Unix type systems) anyone using /tmp for more
permanent stuff will get burned eventually unless they use /var/tmp.

cheers,
Seth W. Klein
-- 
sk at sethwklein.net                             http://www.sethwklein.net/
Maintainer, LFS FAQ                 http://www.linuxfromscratch.org/faq/
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list