The Integrated Smart Protection Service (ISPS) creates and stores IIS logs in the W3SVC4 and W3SVC5 folders.
When deploying more than 1,000 smartscan clients and using the OSCE server's ISPS as the main Reputation server, the size of the IIS log file for these services will consume a significant amount of system drive space.
Create a Windows scheduled task that will delete the log files regularly:
- Save the script below as a vbs file on a local directory (i.e., delete_old_IISLogs_30days.vbs): On Windows Server 2008 and 2012, change the locations indicated on Call DeleteOldLogFiles to C:\inetpub\logs\LogFiles\ (default location).
' Delete all IIS Log Files older than 30 days
Call DeleteOldLogFiles("C:\WINDOWS\system32\LogFiles\W3SVC3", 30)
Call DeleteOldLogFiles("C:\WINDOWS\system32\LogFiles\W3SVC4", 30)
Call DeleteOldLogFiles("C:\WINDOWS\system32\LogFiles\W3SVC5", 30)
Function DeleteOldLogFiles(strPath2Logs, intDays2Keep)
Dim fso, f, fc, f1, strFiles
strFiles = ""
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(strPath2Logs)) Then
Set f = fso.GetFolder(strPath2Logs)
Set fc = f.Files
'-- Determine if file is older than defined days
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > intDays2Keep Then
strFiles = strFiles & f1.Name & vbCrLf
Set f1 = Nothing
Set fc = Nothing
Set f = Nothing
Set fso = Nothing
End FunctionA couple of changes was made especially in the "Delete all IIS Log Files older than 30 days" section. You can also change the logfile path and number of days (the current value is 30) based on your preferences.
- On the OSCE server, go to Control Panel > Scheduled Task.
- Double-click Add Scheduled Task, follow the wizard and provide the following information:
- Browse the script that Windows will execute: delete_old_IISLogs_30days.vbs
- Task Name: Delete IIS Logs older than 30 days
- Set Schedule: Daily
- Set Start Time: 00:00
- Set Start Date: <Same Day>
- Enter Domain Admin Credentials
- Click Finish.
The scheduled task will run daily starting at 00:00 on the day of creation.