[GRASSLIST:162] Re: Temp files and bunnies.

Glynn Clements glynn.clements at virgin.net
Fri May 23 18:43:34 EDT 2003


Soil & Water Lab. wrote:

> We all know of these famous temporary files stored in the ".tmp/${HOSTNAME}" 
> of our machines, that tend to proliferate like rabbits, hence the title of 
> this message. What are they used for ? Most often, they just correspond to a 
> r.mapcalc command I had scripted. Is there any way to get rid of them while 
> still running ? I observed that if I regularly send a rm command to this .tmp 
> directory (by script. I script a lot), I can save a lot of computation time 
> (more precisely, I prevent the iteration time to slow down).
> Any information about the origin of these temp files, and any idea about their 
> eradication would be very welcome

The libgis function G_tempfile() creates files there.

There are two main reasons why you might get files there.

First, the libgis functions which create raster maps store the data
file there while it is being written; once the file is closed, it is
moved to the cell/fcell directory.

Second, programs might call G_tempfile() directly, to create a
temporary file for reasons which are specific to that particular
program.

Programs should delete temporary files once they are done with them. 
However, some programs may omit do so (I'll fix any specific cases of
which I'm made aware); also, if a program terminates prematurely due
to a fatal error, temporary files may be left behind.

In the latter case, it's generally considered to be not worth
significantly complicating a program's source code just to ensure that
temporary files are removed promptly, as such files will be removed
when the session terminates (and when it starts, in case the previous
session was terminated abnormally).

This could be a nuisance if you tend to keep sessions around for days
or weeks.

Unfortunately, manual removal of temporary files during a session
isn't entirely without risk. There are a few instances where temporary
files need to persist after their creator has terminated.

A specific instance of this is d.text. Display (d.*) programs
typically store their command line in the monitor; this is used to
redraw the monitor if it is resized, and also for programs such as
d.save. In order for d.text (which reads the text from stdin) to
record a working command line, its input is saved to a temporary file,
and the stored command line looks something like:

	d.text ... < /path/to/tempfile

If you delete that temporary file, attempts to re-run the command (due
to resizing the monitor, d.redraw etc) will fail.

OTOH, such cases are relatively uncommon. Most temporary files can be
safely removed whenever no command is running.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-user mailing list