I've noticed packages like node-temp and node-tmp, which provide APIs for writing temporary files to the appropriate temp directory for the current OS, e.g. /tmp
.
What are the benefits of doing this, compared with simply storing temporary files in a subdirectory of your module/application (e.g. ./temp
)?
The Temp folder is a directory on your Windows PC used to store temporary files. Clearing the Temp folder is a standard procedure for system administration to reduce the amount of storage space used.
In computing, a temporary folder or temporary directory is a directory used to hold temporary files. Many operating systems and some software automatically delete the contents of this directory at bootup or at regular intervals, leaving the directory itself intact.
The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots. Therefore, data stored in /var/tmp is more persistent than data in /tmp . Files and directories located in /var/tmp must not be deleted when the system is booted.
Practical Data Science using PythonThe tempfile module in standard library defines functions for creating temporary files and directories. They are created in special temp directories that are defined by operating system file systems.
It is certainly operating system specific.
On most Linux systems /tmp
is a tmpfs file system, which works much faster (because all data stays nearly in RAM) than a conventional disk file system.
Also, the official /tmp/
file system is often a setuid directory. This impacts on who has the permission to delete files inside it.
And some systems are administrated specially and might have periodic cron jobs to clean that /tmp
. Also, system administrators know about /tmp/
(and might avoid making backups of it, put it on a fast disk, if not on tmpfs etc...) .... And the Linux Standard Base requires it...
You could use also the TMPDIR environment variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With