Bugtraq mailing list archives

Re: mktemp() and friends


From: benedikt () devnull ruhr de (Benedikt Stockebrand)
Date: Tue, 24 Dec 1996 02:34:45 +0100


Darren Reed <avalon () coombs anu edu au> writes:

Then there are temporary files used in shell scripts - quite often root
cornjobs get implemented to write to some file in /tmp

A more reasonable approach would be to use $UID and/or $$ and/or
$RANDOM and/or `date +%s` (if you've got a GNU date) in the file name.
Like /tmp/cron.daily.`date +%s`.$$ --- one of my favourites.

(I prefer to use /, ~root or /etc).

While it is acceptable to put temporary stuff in ~, /tmp has the
advantage that it may be cleaned up after a reboot.  And consider both
/ and /etc potentially both small and mounted R/O.  So if you want to
stay portable, stick with /tmp.  Finally, what if you're using an
NFS-mounted ~ and run the same stuff on multiple machines --- ok,
that's usually not a problem with ~root, but you can't generalize this
approach.


    Ben

--
Ben(edikt)? Stockebrand    Runaway ping.de Admin---Never Ever Trust Old Friends
My name and email address are not to be added to any list used for advertising
purposes.  Any sender of unsolicited advertisement e-mail to this address im-
plicitly agrees to pay a DM 500 fee to the recipient for proofreading services.



Current thread: