Temps and Logs cleanup -- Any NOT safe to delete?

I was curious if all Temp and Log directories are created equal and if its safe to clean any folder named "Temp" or any Log directory or .log file


Ran command "dir /b /s /ad | findstr "\<Temp\>" | clip
and pasted in notedpad to get an idea of temp directory locations


I know the normal ones are safe to clean, but here are a list of ones I am not quite sure about.
Also the same thing for Logs\*.* or .log   is any of the TEMP or LOG directories not safe to remove or clean?

Besides using CCleaner or etc. is there a command the will look for any folder named "XYZ"
even if you don't know the path (variable) and clean all its contents.

So if you had a folder named TopSecret\Temp\
But you didn't know the parent folders, or directory tree structure. it would clean only the contents of the TEMP directory, and it would find it.

I also have a network drive that has a bunch of profiles, and a lot of this information is sent to archive drives, but the contents has a lot of Temp folders. unknown locations....
The orginal staff along time ago, just made copies into different folders with all users\%username%\blah blah blah temp
they did this all over the place, so the folder could be named "new folder 1" \ users\username\.....
It could be named copy copy\user\username\.......
This goes on tons of times.... and aside from doing a grand search that goes on forever since its a huge TB'sssss Drives... I just want to cleanthem all no matter what directory they are in, and without me specifying...


But as I mentioned, I am curious if any .log log directories or Temp directories are not safe to clean or remove.... Here are some I just came across...


Path for each catagory is listed further down:

#NetBackup Temp
#Inetpub Temp
#CCM -- not even sure what CCM is but all Temp
#Temp Normal: C:\Windows c:\Temp

# User Profile
#NetworkService
#SystemProfile
#Default
#DefaultAppPool
#Classic .NET
#All Users

#MVPSI/JAMS
#PCHealth
#RAC
#Search
#WinSXS \ Temp directory
# Assembly\NativeImages Net v2.0 \Temp
# Assembly\NativeImages Net v4.0 \Temp

# .Net Framework Net v2.0 \Temporary ASP.NET Files
# .Net Framework Net v4.0 \Temporary ASP.NET Files

#System Center Operations Manager 2007 \Temp folders
#DriverStore


#NetBackup

C:\Program Files\VERITAS\NetBackup\Temp
C:\NetBackup Temp

#Inetpub
C:\inetpub\temp\IIS Temporary Compressed Files
C:\inetpub\temp\

#CCM -- not even sure what CCM is
C:\WINDOWS\SysWOW64\CCM\Temp
C:\WINDOWS\SysWOW64\CCM\CIAgent\Temp
C:\WINDOWS\SysWOW64\CCM\CIAgent\Temp\CIDefnDownloads
C:\WINDOWS\SysWOW64\CCM\Inventory\Temp
C:\WINDOWS\SysWOW64\CCM\Inventory\Temp\FileColl
C:\WINDOWS\SysWOW64\CCM\Metering\Temp
C:\WINDOWS\SysWOW64\CCM\ServiceData\Temp

#Temp
C:\WINDOWS\Temp\
C:\Temp

#Web Extentions
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS\


# User Profile

C:\Documents and Settings\%username%\Temp
C:\Documents and Settings\%username%\Local Settings\Temp
C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files

C:\Users\%username%\AppData\Local\Temp
C:\Users\%username%\AppData\Local\Temporary Internet Files
C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files

#NetworkService

C:\Documents and Settings\NetworkService\Temp
C:\Documents and Settings\NetworkService\Local Settings\Temp
C:\Documents and Settings\NetworkService\Local Settings\Temporary Internet Files

C:\Users\NetworkService\AppData\Local\Temp
C:\Users\NetworkService\AppData\Local\Temporary Internet Files
C:\Users\NetworkService\AppData\Local\Microsoft\Windows\Temporary Internet Files


#SystemProfile

C:\WINDOWS\system32\config\systemprofile\Local Settings\Temp
C:\WINDOWS\system32\config\systemprofile\Local Settings\Temporary Internet Files
C:\WINDOWS\system32\config\systemprofile\Local Settings\Temp
C:\WINDOWS\system32\config\systemprofile\Local Settings\Temporary Internet Files

C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\Temporary Internet Files
C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\Temporary Internet Files
C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files
C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files
C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp
C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp

#Default

C:\Documents and Settings\Default\Temp
C:\Documents and Settings\Default\Local Settings\Temp
C:\Documents and Settings\Default\Local Settings\Temporary Internet Files

C:\Users\Default\AppData\Local\Temp
C:\Users\Default\AppData\Local\Temporary Internet Files
C:\Users\Default\AppData\Local\Microsoft\Windows\Temporary Internet Files

#DefaultAppPool

C:\Documents and Settings\DefaultAppPool\Temp
C:\Documents and Settings\DefaultAppPool\Local Settings\Temp
C:\Documents and Settings\DefaultAppPool\Local Settings\Temporary Internet Files

C:\Users\DefaultAppPool\AppData\Local\Temp
C:\Users\DefaultAppPool\AppData\Local\Temporary Internet Files
C:\Users\DefaultAppPool\AppData\Local\Microsoft\Windows\Temporary Internet Files

#Classic .NET

C:\Documents and Settings\Classic .NET AppPool\Temp
C:\Documents and Settings\Classic .NET AppPool\Local Settings\Temp
C:\Documents and Settings\Classic .NET AppPool\Local Settings\Temporary Internet Files

C:\Users\Classic .NET AppPool\AppData\Local\Temp
C:\Users\Classic .NET AppPool\AppData\Local\Temporary Internet Files
C:\Users\Classic .NET AppPool\AppData\Local\Microsoft\Windows\Temporary Internet Files


#MVPSI/JAMS

C:\Program Files\MVPSI\JAMS\Agent\Temp

#PCHealth

C:\WINDOWS\PCHealth\HelpCtr\Temp


#RAC
C:\ProgramData\Microsoft\RAC\Temp
C:\Users\All Users\Microsoft\RAC\Temp

#Search

C:\ProgramData\Microsoft\Search\Data\Temp
C:\Users\All Users\Microsoft\Search\Data\Temp

# Assembly\NativeImages Net v2.0 \Temp

C:\Windows\assembly\NativeImages_v2.0.50727_32\Temp
C:\Windows\assembly\NativeImages_v2.0.50727_64\Temp

# Assembly\NativeImages Net v4.0 \Temp

C:\Windows\assembly\NativeImages_v4.0.30319_32\Temp
C:\Windows\assembly\NativeImages_v4.0.30319_64\Temp


#WinSXS

C:\Windows\winsxs\Temp
C:\Windows\winsxs\Temp\PendingDeletes
C:\Windows\winsxs\Temp\PendingRenames

#DriverStore
C:\Windows\System32\DriverStore\Temp

#System Center Operations Manager 2007

C:\Program Files\System Center Operations Manager 2007\Health Service State\Monitoring Host Temporary Files

# .Net Framework Net v2.0 \Temporary ASP.NET Files

C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files

# .Net Framework Net v4.0 \Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files

#All Users
LVL 5
IndyrbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
>>I was curious if all Temp and Log directories are created equal
No, this depends on the application.

>>if its safe to clean any folder named "Temp" or any Log directory or .log file
No general answer can be given here, 'temp' is used for several purposes. Decent applications only write real temporaty data to temp locations. For those applications you are safe to delete everything, when it's still in use you'll get a warning. Applications that use 'temp' to store recovery information may be very useful, deleting those files is not recommend. For example: an office application may store something that is deleted when the office application is closed normally. When closed abnormally it uses the recovery information to recover your important document for you.

For 'log' I'd be a bit more selective in deleting, log locations should contain just log files that are safe to delete but you may loose useful info when you're debugging something. Logfiles can get big, you could decide to truncate them once and a while.

I usually just clean windows\temp and userprofile\local settings\temp based on the timestamp, leaving files newer than a week for what they are. Browser caches I never clean, I set them to a fixed size that is reasonable.

When cleaning is not sufficient, I use some tool like windirstat for example to file large files/directories and clean some more.
0
IndyrbAuthor Commented:
I definitely understand you point. and in your example where you clean the
c:\temp c:\windows\Temp and and users on c:\users\%username%\......\Temp
or Temporary Internet files....

Those are the known paths...

What I am say... Is I have a File server where people just made copies and copies and copies of various profiles including temp and temporary internet files.... the copies have unknown folder names.... so aside from messing with anything on the C: (OS drive) or the D:\(Data\APP Install) drive

I want to browse the Z: drive where all the garbage lives... I can delete everything and start over, I just want to clean up the stuff we don't need. And the complete struycture is ever changing, so I wanted to use possible variables.

Curious if using a script, command line or powershell to do a mass find and delete..

Thoughts?

I was looking at possible command line: with lets say (Temporary Internet)
using the for, dir, and find and either rmdir or del commands..

But what I am uncertain is, if it scans through every directory. no mater how far deep or wide.

Thoughts:

Z: drive\\\    for /F "delims=" %i in (dir /s /ad |findstr "\<Temporary\>") do del *.* /f /q %I
Z: drive\\\    for /F "delims=" %i in (dir /s /ad |findstr "\<Temporary\>") do rmdir /s /q %I

or via file with the path in includefolders.txt
\Temporary\*.*
"\<Temporary\>"

 for /F "delims=" %i in (path to include.txt) do del /f /q %I


I am not at the location to give this a test.. but though I would write it down for discussion and though


Do you know of a way to do this via powershell and vbscript where it seeks and destroys all content including directories in any folder named ((Temporary Internt)) on the Z: drive
0
SteveCommented:
Questions like this can trigger a big debate, as views on temp files are very subjective and everyone has their own view.

The only hard & fast rule here is:
Do not delete it if you do not know what its for.

With that in mind, any time you are unsure of a folder/file's purpose, just leave it.


In general, everyone's view of a 'temp' folder is different. Microsoft intended the default 'temp' as a short term, non critical storage location.
Many software/app developers don't share this view, however. This means that many poorly designed {in my opinion} programs store files in the temp folders that they actually NEED.

There is never a definitive answer therefore, because it depends what programs you have installed and use.

As a general guide, anything user related is unlikely to cause much harm if deleted, so user temp folders are normally safe to empty. The main administrator users may need care however, as many programs and services store data in these folders.

The various temp folders in windows directories are also usually safe to clear, but caution should be taken on servers as the file may still be needed.

temp internet files are usually seen as safe to clear, as are many log file folders.
(note: exchange & SQL creates logs that may be required so take care deleting these if you are unsure)
one advantage with log files is they are usually just plain text, which means you can zip them up really small without deleting them. if you last a week/month without a problem you can probably go ahead and delete the zipped log files. if stuff breaks you can unzip them and put them back.

FYI, programs like 'tempcleaner' are really handy and let you clear up loads of folders in one go. Always assess the selected options before pressing the 'clean/go' button though as you should always ensure you are happy with the folders such programs are actually going to empty.
0
Webinar: Miercom Evaluates Wi-Fi Security

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom how WatchGuard's Wi-Fi security stacks up against the competition in our upcoming webinar!

IndyrbAuthor Commented:
Thanks for the response, I understand the points listed above...

However can you advice if these "Microsoft locations are safe to clean" Only Microsoft. Not other apps...

If you could just quickly look at the list below, and specify if it is safe, or needs to stay. That would be awesome.

#Inetpub
C:\inetpub\temp\IIS Temporary Compressed Files
C:\inetpub\temp\

#CCM
C:\WINDOWS\SysWOW64\CCM\Temp
C:\WINDOWS\SysWOW64\CCM\CIAgent\Temp
C:\WINDOWS\SysWOW64\CCM\CIAgent\Temp\CIDefnDownloads
C:\WINDOWS\SysWOW64\CCM\Inventory\Temp
C:\WINDOWS\SysWOW64\CCM\Inventory\Temp\FileColl
C:\WINDOWS\SysWOW64\CCM\Metering\Temp
C:\WINDOWS\SysWOW64\CCM\ServiceData\Temp

#Temp
C:\WINDOWS\Temp\
C:\Temp

#Web Extentions
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS\

# Any User Profile

C:\Documents and Settings\%username%\Temp
C:\Documents and Settings\%username%\Local Settings\Temp
C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files

C:\Users\%username%\AppData\Local\Temp
C:\Users\%username%\AppData\Local\Temporary Internet Files
C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files

#NetworkService

C:\Documents and Settings\NetworkService\Temp
C:\Documents and Settings\NetworkService\Local Settings\Temp
C:\Documents and Settings\NetworkService\Local Settings\Temporary Internet Files

C:\Users\NetworkService\AppData\Local\Temp
C:\Users\NetworkService\AppData\Local\Temporary Internet Files
C:\Users\NetworkService\AppData\Local\Microsoft\Windows\Temporary Internet Files


#SystemProfile

C:\WINDOWS\system32\config\systemprofile\Local Settings\Temp
C:\WINDOWS\system32\config\systemprofile\Local Settings\Temporary Internet Files
C:\WINDOWS\system32\config\systemprofile\Local Settings\Temp
C:\WINDOWS\system32\config\systemprofile\Local Settings\Temporary Internet Files

C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\Temporary Internet Files
C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\Temporary Internet Files
C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files
C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files
C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp
C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp

#Default

C:\Documents and Settings\Default\Temp
C:\Documents and Settings\Default\Local Settings\Temp
C:\Documents and Settings\Default\Local Settings\Temporary Internet Files

C:\Users\Default\AppData\Local\Temp
C:\Users\Default\AppData\Local\Temporary Internet Files
C:\Users\Default\AppData\Local\Microsoft\Windows\Temporary Internet Files

#DefaultAppPool

C:\Documents and Settings\DefaultAppPool\Temp
C:\Documents and Settings\DefaultAppPool\Local Settings\Temp
C:\Documents and Settings\DefaultAppPool\Local Settings\Temporary Internet Files

C:\Users\DefaultAppPool\AppData\Local\Temp
C:\Users\DefaultAppPool\AppData\Local\Temporary Internet Files
C:\Users\DefaultAppPool\AppData\Local\Microsoft\Windows\Temporary Internet Files

#Classic .NET

C:\Documents and Settings\Classic .NET AppPool\Temp
C:\Documents and Settings\Classic .NET AppPool\Local Settings\Temp
C:\Documents and Settings\Classic .NET AppPool\Local Settings\Temporary Internet Files

C:\Users\Classic .NET AppPool\AppData\Local\Temp
C:\Users\Classic .NET AppPool\AppData\Local\Temporary Internet Files
C:\Users\Classic .NET AppPool\AppData\Local\Microsoft\Windows\Temporary Internet Files

#PCHealth

C:\WINDOWS\PCHealth\HelpCtr\Temp

#RAC
C:\ProgramData\Microsoft\RAC\Temp
C:\Users\All Users\Microsoft\RAC\Temp

#Search
C:\ProgramData\Microsoft\Search\Data\Temp
C:\Users\All Users\Microsoft\Search\Data\Temp

# Assembly\NativeImages Net v2.0 \Temp
C:\Windows\assembly\NativeImages_v2.0.50727_32\Temp
C:\Windows\assembly\NativeImages_v2.0.50727_64\Temp

# Assembly\NativeImages Net v4.0 \Temp
C:\Windows\assembly\NativeImages_v4.0.30319_32\Temp
C:\Windows\assembly\NativeImages_v4.0.30319_64\Temp


#WinSXS
C:\Windows\winsxs\Temp
C:\Windows\winsxs\Temp\PendingDeletes
C:\Windows\winsxs\Temp\PendingRenames

#DriverStore
C:\Windows\System32\DriverStore\Temp

#System Center Operations Manager 2007
C:\Program Files\System Center Operations Manager 2007\Health Service State\Monitoring Host Temporary Files

# .Net Framework Net v2.0 \Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files

# .Net Framework Net v4.0 \Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
0
Gerwin Jansen, EE MVETopic Advisor Commented:
I'm sorry, for such a big list, I'm not going to do the research for you. Please read the advice we're giving you, do some testing yourself. What is your goal anyway besides satisfying curiosity?
0
SteveCommented:
As advised, without knowing what apps you run we cant really advise if most folders are 'safe' to empty.

Unless you can be sure it wont affect your systems, i'd recommend sticking to the folders you have titled #Temp# Any User Profile

To sort the others you may need to research the software that relates to each 'temp' folder and assess if its safe or not.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.