SUMMARY: Scripts for clearing out /tmp

From: Adam Kirby <A.Kirby_at_eim.surrey.ac.uk>
Date: Thu May 24 2001 - 13:28:56 EDT
Apologies for the delay.

I had quite a mixture of responces from people about this :

- Renaming /tmp to /tmp-old, recreating /tmp with newfs and then deleteing
  /tmp-old.

- Use find but replace the "| xargs rm -f"  with "-exec rm {} \;"

- Use the mtime option to find to only remove file that are over x days
  old.

- (rm -rf /tmp ; mkdir /tmp ; chown root.root /tmp ; chmod 1777 /tmp) in a
  startup script.

A couple of people drew my attention to possible security implications
when using a "find .. | xargs rm -f" as root. See the following page for
more details : http://www.securityfocus.com/archive/1/4494

I am still in two minds about what to use. I think it will either be
creating a new file system at boot time but I'm slightly concerned about
the delay that this will cause, or use the following as a cronjob :

"/usr/bin/find /tmp ! -name 'lost+found'  ! -name 'ps_data'  ! -type l
! -user root -atime +7 -exec rm -rf {} \;"

Thanks go to Andrew Brennan, Casey Jones, Sean Quaint, Vince Merrell,
Lieven Marchand, Arun Gurung, Rick Francis and James R Grinter for their
responces.

Original Mail:
--------------------------------------------------------------------------
I have a few E10k domains that have standard UFS /tmp's which obviously
don't get emptied upon reboot as tmpfs /tmp's do. I've been using a simple
startup script that does the following :

/usr/bin/find /tmp ! -name 'lost+found' ! -name 'ps_data' | xargs rm -f

I was just wondering if anyone had a more elegant script that provides
better functionality.
--------------------------------------------------------------------------

Cheers, Adam.
Received on Thu May 24 18:28:56 2001

This archive was generated by hypermail 2.1.8 : Wed Mar 23 2016 - 16:24:55 EDT