Iis – Automatically Clear IIS Logs Periodically

iisiis-6log-fileswindows-server-2003

We have an IIS server on a Windows Server 2003 box where the log files keep filling up the hard disk. What I am looking for is a scheduled process that every once in a while will go in and clean up the logs, deleting anything older then a month. Does something like this already exist or is there a simple script out there I can use and setup as a scheduled task?

Best Answer

Nothing like this is built into Windows, not at least Win2k3 or earlier. You can find dozens of scripts, in your language of choice, to accomplish this. I would use something like a BAT script that called forfiles.exe for anything over 30 days, and have it be scheduled to run daily using Scheduled Tasks.

Also, if your log files are on the system volume, move them to a different volume so when they fill the disk, they don't take the server down.

Related Topic