I have created a folder in Windows, C:\tmp\ and I want it to behave like /tmp/ folder in Linux, i.e. its contents are removed every time the system is booted.
I think the commands to run could be (at least on windows 7):
RD C:\tmp /S /Q
MKDIR C:\tmp
A way to execute this commands on every boot? Or, any better way to accomplish this?
You should use the environment variable %TEMP% which points to different locations on different Windows versions, but is the defined location for temporary data in Windows.
LAST UPDATED: MAY 24, 2022 On your keyboard, press the Windows + R keys at the same time. In the Open field, type %temp%, then press ENTER. The temp folder will open. You can also access it on your Windows 10 PC via the shortcut button below, then choose Temporary files.
Web servers have a directory named /tmp used to store temporary files. Many programs use this /tmp directory for writing temporary data and generally remove the data when it is no longer needed. Otherwise the /tmp directory is cleared when the server restarts.
By default, all the files and data that gets stored in /var/tmp live for up to 30 days. Whereas in /tmp, the data gets automatically deleted after ten days. Furthermore, any temporary files that are stored in the /tmp directory get removed immediately on system reboot.
You should use the environment variable %TEMP%
which points to different locations on different Windows versions, but is the defined location for temporary data in Windows.
Windows doesn't clean it up by itself, but it is fine to delete its contents on shutdown (and as lots of applications don't clean up properly, it is recommended to do so once in a while).
Do not delete the %TEMP%
folder, but it's contents using del %TEMP%\* /s /f /q
which will delete the contents instead, so you don't need to recreate the folder.
For setting up a shutdown-script, use the answer provided by @Alex K.
I do it via a shutdown script to clear a directory called c:\null
Run gpedit.msc
& see http://technet.microsoft.com/en-us/library/cc770300.aspx for instructions on configuring a script to run.
The bat file I run is
@echo off
@rd c:\null\ /s /q
@md c:\null
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