Clean up Logfiles in Exchange

Published by TheBlogger on

We’ve probably all been there! Installed Exchange, just to find out after a few days it is filling up the disk(s) with numerous logfiles, eventually resulting in a dismounted database. The first time this happened you have no clue at all. Why did the disk(s) fill up? After desparately going over the internet (with your boss breathing down your neck (“You’re the IT-Guy”)) you found the problem (LOGFILES), and probably also a way to remove those “old” logfiles.

Great, solved !

After a while you started to create (or copy/paste, whatever) scripts to not only truncate those pesty logfiles, but also other logfiles. You even found a script to move logfiles from the default C-drive to another drive. So now the system is running smooth, no more disk-problems.

But then, after a shutdown and restart, you notice that 1 or more of your databases won’t mount anymore. What the **?

There is plenty of space on disks, so why are they dismounted ?

Panic !!

Luckily there is this “EseUtil.exe /p“, so you’re up and running fairly fast (people might be missing a number of emails, but at least, the database(s) can be mounted (phew)).

But why did they get dismounted in the first place, or (because it turns out that that’s the problem) why did the logfiles become corrupted??

Probably because, when the system was shutting down, not all logfiles were committed to the database, hence resulting in a dismounted database after the restart.

Ok, but how do you commit the logfiles to the database? You can run a backup (Windows Backup), that will commit and clean up the logfiles, but that would take a lot of time (and maybe we don’t even have enough diskspace for it, because we use a different approach for backups with our VM’s).

Here’s a Batch-file that will commit all logfiles to the Exchange-databases, then shut down all Exchange services. You can run this batchfile standalone, but you can also add it to a ShutDown-GPO for Exchange-Server, thus assuring that with every shutdown/restart this batchfile will be executed.

Because this batchfile also cleans up the Exchange logfiles (after committing the database the committed logfiles are removed), you could also take that specific part out of this batchfile, and use it for your daily cleanup of the logfiles. But that’s entirely up to you.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *