Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

We are thinking to make our web application hosted on a windows server 2003 machine create temporary files, and "leave" it there as such. We won't manually take any action on them. So will these files get automatically deleted? Or is there some sort of policy we have to configure - like these files should get deleted after 30 days or so...

Update:

A production server will hardly get shutdown. What to do then if the files have to be deleted somehow?

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

No, there's nothing turned on by default in Windows that will automatically delete temp files. Not on shutdown, not on reboot, not ever.

The Disk Cleanup tool has an option to do that when its run.

The proper way to handle this is for your web application to clean up after itself in some way. You might have it delete orphaned files when a user logs out, for example. Or a (small) random chance that a "cleanup sweep" will be made on every request. Or a scheduled task that must be installed and configured to do cleanup. Or a scheduled task to run Disk Cleanup.

Do not go about just "leaving stuff" in the temp folder in the hopes that something will come along and clean up your mess for you.

Also, when you do go about cleaning up your files, only touch the files that you've created and no others. Other applications may need those files. If tracking your own files is too much trouble, create a folder that you can safely empty at will.

share|improve this answer
3  
Agree. Everyone should clean up after themselves, even applications. –  Nifle Aug 3 '11 at 13:46
2  
Mother was right?!?! –  music2myear Aug 3 '11 at 14:00
    
@music2myear: Yes, yes she was. :-) –  afrazier Aug 3 '11 at 14:10
    
Hey, I guess the good news is I'll have something worthwhile to thank her for next mother's day. ;) –  music2myear Aug 3 '11 at 14:13
add comment

Because you are speaking of a server with high availability, a scheduled task is the best way to go. You could do something as simple as a vbscript or batch file that finds all files over a certain date and purges them. Adjust the frequency of the schedule based on how quickly the temp files accumulate in order to minimize the load on the server on any given run.

Thomas Maurer has a powershell script that allows a pretty high level of flexibility, such as specifying the age of the files to be removed, the folder they are to be removed from, etc.

UPDATE: Thomas Maurer's site isn't loading for me, so I ran a google search for "powershell delete files older than 30 days" and the results look promising.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.