How to work and handle temporary files ?>

How to work and handle temporary files

A temporary file is a file that can be created by a program when it can not allocate enough memory for tasks or the operating system, in some cases, make backups before the amendment of certain file for security reasons, so, if missing information or other catastrophe, it can restore the file to its original state. Some programs create files and not eliminate them. This can happen because the program crashes or because the developer forgot to add to the program the need to delete temporary files after the program has created them. Temporary files left aside accumulate much disk space over time although you can use a number of system utilities, called cleaners of temporary files, or disk cleaners which serve to solve this problem.

Microsoft systems,  usually, in temporary files have the .TMP extension. However, in the Unix family systems like GNU/Linux or OS X, usually hidden files with their original name and extension but with the character ~ in extension. In all known operating systems there is a directory where usually temporary files are housed, in the case of systems Unix are in the / tmp and in Microsoft there is a directory in the folder where it is installed system.

What to do with temporary files in MS Windows

A number of files may appear on the hard drive in various directories beginning with a tilde character (~) and ending with a .TMP extension. These may be temporary files created by Windows that remain on the hard drive due to an irregular exit from a Windows session.  Under normal conditions, these files are closed and deleted by Windows when you quit a Windows session. However, if you quit Windows in an irregular way (for example, restarting the computer or turning it off during an active Windows session) the files are not closed or deleted. The temporary files should be located in a designated subdirectory of their own. If temporary files appear in the root directory, you may have an invalid SET TEMP statement. Check for the following conditions:

    1. Using a text editor, such as Microsoft Windows Notepad, open the AUTOEXEC.BAT file and make sure it includes a valid SET TEMP statement. This statement should be similar to the following:


  1. Note the path that the SET TEMP statement points to and check to ensure that such a subdirectory does exist. If not, create a subdirectory to match the SET TEMP statement.
  2. If the SET TEMP statement is pointing to a RAM drive, make sure the RAM drive is large enough to hold the temporary files being created.

By ensuring that there is a valid SET TEMP statement and a separate subdirectory for temporary files, these files can easily be deleted on a regular basis.
To delete a temporary file, use the following steps:

  1. Close Windows.
  2. From the MS-DOS command prompt, change to the TEMP directory.
  3. Delete any existing .TMP files. Make sure Windows is not running at the time these files are deleted. Some of these .TMP files may be files that Windows is using.

Taken from Microsoft Web

What to do with temporary files in Linux

In Linux, the handle of temporary files is different, folders /tmp and /var/tmp can store temporary files, but its use is slightly different. When a program writes temporary files in /tmp, there is no assurance that it will find them the next time it is executed. This binder can be purged at any time. In most distributions, this folder is emptied each time the system is restarted.

Instead, files written to /var/tmp are retained after rebooting the PC and should not being removed.