How to automatically clean up buildAgent/work directories

We're running TeamCity 4.5.1, and we're getting a lot of old checkouts hanging around in our build agents' "work/" directories.  For example, on one build agent we have:

2a9cfb1ae34806a   740c2934852ae0a8  c0e9e816f2f55b75  e81467c7ea8ac98f
2db4997e9833d346  7bb7480db510a6ee  c7a63048c87fc960  fast.svn.update.dat
43db3477f03ac070  b15356c66bd799cf  cf4122c86ade93cd
4bd5c9c0b8adf731  bbf3df71b87d0564

in the "work/" directory.  Many of these directories haven't been touched for days and have large builds residing in them.  Is there any way to get TeamCity to clean them up automatically? Note that we're already doing clean builds.  The problem occurs because TeamCity checks out a build to a new directory for whatever reason and seems to forget about the old one. I can write a script that runs as a cron job to do the cleanup, but I'd like to configure TeamCity to do it if possible.



Hello Tom,

   Actually, TeamCity automatically cleans up unused checkout directories. Please read about this at



Ok.  I've set the appropriate parameters to 24 hours in each of the build agents.  I'll have a look tomorrow and see if it has cleaned up the unused directories. Thanks.


Hi Tom,

  How it goes, if the timeout helps?



Please sign in to leave a comment.