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

Re: Files in the /tmp dir.

Sthu Deus wrote:
> I have a bunch of such files:
> -rw------- 1 root    root     0 2010-10-26 12:14 /tmp/tmp.VpjBPrFKtT
> What can these be? From whence they come?
> It seems they are created every minute after some period of days.

That is the default template name from the 'mktemp' command.  The
mktemp command is often used in shell scripts to create temporary
files.  The typical use of it is to specify a different name than the
default so that tracking down where they come from is easier.  But
here in the above someone just used the default name.

This tells me that some task on your system has been added that is
using mktemp to create a temporary file but is not cleaning it up
afterward.  This task is not a standard system task but something
someone has created as an addition because all of the system tasks are
well behaved and both use a name and also clean up after themselves.

  $ mktemp
  $ ls -ldog /tmp/tmp.1oeywpqtzh
  -rw------- 1 0 Dec  6 11:02 /tmp/tmp.1oeywpqtzh

But in a script it would be typically used like this:

  trap 'rm -f $tmpfile' EXIT
  tmpfile=$(mktemp -t myscript.XXXXXX) || exit 1

The trap will remove the temporary file when the script exits.[1]


[1] Things are a little more complicated.  That is the way it is
supposed to work.  That is the way it works in all shells except one.
But 'dash' breaks this.  In 'dash' you need something more complicated
when I will save your eyes from at this moment.

Attachment: signature.asc
Description: Digital signature

Reply to: