[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: clean out /tmp?

Mike McCarty wrote:
> I've been doing that ($ rm /tmp/*) while up (I use Gnome over Xwindow).
> Am I playing with fire? What are the possible consequences?

One of your programs crashes or misbehaves...

$ ls /tmp

(That's on a tmpfs filesystem, on a system that's been up since this
morning. So any files are those that have been created and used today.)

I don't pretend to know exactly what all of them do. But you might
expect there to be potential problems with one of them.

For example, if I were to finish editing this e-mail, exit vim, delete
all the mutt-kendrick files, then ask mutt to send this e-mail, I
wouldn't expect there to be any copy of this e-mail left for mutt to

The orbit directory might worry me: I don't know enough about ORBit to
be sure deleting it wouldn't affect anything.

One other consequence you might not expect: on Unix systems, files can
appear in the directory tree more than once (hard links). Once a program
has a file open, it refers to it by a file handle, not a file name.

All rm does is unlink the specified files: a file is only deleted when
its link count goes to zero and no program still has it open. So if a
program has a temporary file open, and you rm it, it's still present on
disk (or in tmpfs), and the program can still use it, until the program
exits or closes the file.

(Some programs use this to create and use per-process temporary files
that don't appear in the directory listing. That way, if the program or
the machine crashes, the temporary files will automatically be cleaned
up. You also hear of database machines where the main database is
accidentally rm'ed. But all is not lost: the database is not deleted
until all existing programs that have direct connections to it are
deleted. So those existing connections can be used to dump the data in
the database, and it can be recreated...)

Note that neither your or my commands shows the hidden files in /tmp.


E-mail address: james | "The duke had a mind that ticked like a clock and,
@westexe.demon.co.uk  | like a clock, it regularly went cuckoo."
                      |     -- Terry Pratchett, Wyrd Sisters

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]