Search WWW Search

Saturday, August 19, 2006

Exchange: Managing SMTP and IIS Log Files via Script


Exchange can can log a number of transactions such as SMTP, IIS, or Message Tracking. These logs play an important role in troubleshooting, trending as well as a number of other things. However, Exchange or IIS does not provide an option to automatically purge SMTP or IIS logs. In this article, I will provide an example to manage these log files.


Since you want to always keep a copy of your log files, for example 30 days worth before purging them, what this script will do is first move all log files from the directory you specify to another partition E:\logs that are older than 30 days, then delete any log files older than 60 days from E:\logs.

1. Create a folder in C:\scripts (Or anywhere you want to designate)

2. Download WaRmZip from SoureForge. Download file to C:\scripts

3. Open notepad and enter the following:

:: movelogs.bat
:: moves log files from the directory you specify below


waRmZip.wsf /r /q "C:\logs" /ma:30 /md:E:\Logs_Old

This script will move any log files older than 30 days from C:\logs to E:\logs_old folder. You will need to modify this line to point to where your SMTP or IIS logs are and your destination path. Save this file as movelogs.bat

4. Open notepad and copy the following:

:: deletelogs.bat
:: Delete logs older than 60 days to run every 60 days.


waRmZip.wsf /r "E:\Logs_Old" /da:60 /df /q

Save this file as deletelogs.bat

5. Now go to scheduled tasks and schedule movelogs.bat to run monthly and deletelogs.bat to run every 60 days.

Note: Ensure you test this using test directories before implementing them into production. I have also provided these files on "Chong Man"s Exchange Resources" under links.

James Chong
MCSE M+, S+, MCTS, Security+

How useful was this article? Want to see a tip not listed? Please leave a comment.


Anonymous EvylRat said...

This article is very useful. I've been messing around with VB scripts all morning, but this is very simple to understand and modify. It's exactly what I've been looking for!

5:05 AM  
Blogger longge said...

Do you think the stylish of Hogan scarpe
suitable you? hogan donna
is a very good handbag’s brand but it still can offer many good shoes for you! Hogan scarpe uomo
really a very good shoes brand! Hogan scarpe donna
cater the needs of every fashion.

6:47 PM  
Anonymous Anonymous said...

I get

Line 856
Char 6
"The Handle is invalid".

5:54 AM  

Post a Comment

<< Home

xml:lang="en" lang="en"> MS Exchange Tips: Exchange: Managing SMTP and IIS Log Files via Script