Large IIS log files
Here’s a nice little tip to shrink or keep control of your IIS log files. While looking at a space issue on a server recently I noticed that their W3SVC3 (this might be different i.e. W3SVC1) log files were about 4-5Gb in size and contained thousands of log files.
In order to cut these down, you can either delete them manually and leave the last 30 days worth or run either of these commands depending on how you want to manage the log files:
Forfiles /P C:\WINDOWS\system32\LogFiles\W3SVC1 /S /M *.log /D -30 /C “cmd /c del @PATH” (Change “C:\WINDOWS\system32\LogFiles\W3SVC1” to where every your logs are located)
You can Schedule this to run say every 30 days to keep them in check by running the command below, this will create a scheduled task.
at 12:00 /EVERY:Su Forfiles /P C:\WINDOWS\system32\LogFiles\W3SVC1 /S /M *.log /D -30 /C “cmd /c del /F @PATH”
(Change “C:\WINDOWS\system32\LogFiles\W3SVC1” to where every your logs are located)
Hope this gets you out of a sticky Quibble.
Terrific Post! Very helpful. I’ll be using FORFILES.exe a lot in the future.
Thank you,
RN
No worries you’re more than welcome, don’t forget to support the site! Thanks