Is it safe to rm -rf /tmp/*?

In general, no.

If it's filling up with junk, you may want to look at what software isn't cleaning up after itself.

You can also use find to identify files which haven't been modified or accessed in a long time that are probably safe to delete.


The real answer is - it depends. /tmp may be used by applications that require lockfiles or temporary logs to be present in order to run, or it may not. There may be symlinks in there...not sure what for, but it's always possible.

You should really look at what is in there before you decide to remove it. doing an rf -rf * on anything is inherently dangerous.


No. For example, if you have a MySQL database running on your computer that will kill its socket, or if you are using emacs as a server that will kill the server process. There are many other cases where it is not safe to remove these files. The best thing to do is to write a script which checks the date of the file and only removes it if it is old.

Tags:

Tmp