# deleting /tmp directory

## shmurfect

For some reason my /tmp directory isn't being cleared every reboot.  It says it is clearing the /tmp directory when the compter starts up, but it doesn't.  What can I do to fix this?

----------

## daos

I mount the /tmp folder on the RAM using tmpfs, so the content is gone after reboot. Besides, it's faster since all files are on RAM.

Put this line in /ect/fstab

tmpfs /tmp tmpfs  defaults 0 0

Note: the default max size for /tmp on RAM is half of ram size. It's dynamic and only the number of files on /tmp occupies the RAM. You can limit the max size (e.g 32MB):

tmpfs /tmp tmpfs size=32m defaults 0 0

You need to have the tmpfs  filesystem (formerly shm) compiled in the kernel to make it work.

----------

## shmurfect

 *daos wrote:*   

> I mount the /tmp folder on the RAM using tmpfs, so the content is gone after reboot. Besides, it's faster since all files are on RAM.
> 
> Put this line in /ect/fstab
> 
> tmpfs /tmp tmpfs  defaults 0 0
> ...

 

hmm - yea - that sounds like a good idea.  but say i want large files in the /tmp directory (say iso's or something).  Is there any way to have this folder deleted everytime the box is restarted or such without having a ram disk?

----------

## daos

You can try this to see if it works.

In the system boot scripts (rc.sysinit for redhat or mandrake), before /tmp is mounted in the script:

rm -rf /tmp

mkdir /tmp

chmod 1777 tmp

----------

