SUMMARY: Scripts for clearing out /tmp

From: Adam Kirby <>
Date: Fri May 25 2001 - 08:15:31 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

- 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

- (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 :

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

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 Fri May 25 13:15:31 2001

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