Large TFSUser\AppData\Local\Temp Directory on Build Machine

女生的网名这么多〃 提交于 2019-12-18 19:08:41

问题


I'm using TFS 2012 Update 1 on Windows Server 2008 R2. We have the TFS build running under the account TFSUser. The other day we ran out of space on our build machine. Upon investigation I found that the folder C:\Users\TFSUser\AppData\Local\Temp had over 50GB of files in it, some dating back as far as October of 2012. None of the files are overly large, but they don't ever seem to get cleaned up.

Investigating today shows that folder gets written to a lot during an automated build. Why aren't these files getting cleaned up and what can I do to ensure my build machine doesn't run out of space again due to this issue?

Update 2013-03-13
I created a small powershell script that runs nightly to delete the temp directory contents. Here's the powershell script:

Stop-Service TFSBuildServiceHost.2012
Remove-Item Drive:\Path\To\TFSUser\AppData\Local\Temp\* -recurse -exclude Build*
Start-Service TFSBuildServiceHost.2012

I have the task run with elevated privileges nightly as the TFSUser account. The elevated privileges are needed because we need to start and stop services.


回答1:


This is a TFS2010 issue that I guess they haven't addressed in 2012 yet. The build system creates temp files and never cleans them up, leading eventually to failures because the disk is full or because they use a limited number of digits for the unique IDs and run out of new ids that can be used (IIRC, it falls over at 65536 files, which we usually hit long before we run of disk space)

The solution is to delete the temp files periodically. I just do this manually about 2-4 times a year. The safest approach is probably to disable your build agents and then clean out the temp folder, then re-enable the agents (and it may not be a bad idea to reboot the server at the same time if it's been running for months).

An alternative may be to set up a small scheduled task daily/weekly that cleans away any temp files older than a few days old, and run it in the middle of the night when you know nothing else (like overnight builds) will be running.

Or if your server is rebooted several times a year anyway, a start-up script that cleans out the temp folder before the build agents start up may be a clean & tidy solution.

It all depends how quickly your disk is filling up - you'll probably find that it's many months of accumulated cruft rather than something that hits you after a short time, in which case you don't need a very aggressive approach to keep things running smoothly.



来源:https://stackoverflow.com/questions/15371702/large-tfsuser-appdata-local-temp-directory-on-build-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!