Home > other >  IIS log using a script regularly cleaned
IIS log using a script regularly cleaned

Time:12-11

1, use the script to delete the IIS log
(1) write the script, create the script name for retentionscript. VBS
VBScript will check folder under the term of use of each log file and will delete any earlier than using the time limit specified log file, for the purpose of your custom script, just change the name of the folder in the script of line 1 and the path, then in line 2 days as the unit of the longest maturity of a change to the desired value,
 
SLogFolder="c: \ inetpub \ logs \ LogFiles" ` IIS log path
IMaxAge=30 'in days ` keep time, unit for day
The Set objFSO=CreateObject (" Scripting. FileSystemObject ")
The set colFolder=objFSO. GetFolder (sLogFolder)
For Each colSubfolder colFolder. In SubFolders
The Set objFolder=objFSO. GetFolder (colSubfolder. Path)
The Set colFiles=objFolder. Files
For Each objFile colFiles in
IFileAge=now - objFile. DateCreated
If iFileAge & gt; (iMaxAge + 1) then
ObjFSO. Deletefile objFile, True
End the if
Next
Next

(2) execute the script to delete the IIS log:
To run the script manually, please execute the following script in the administrator command line:
 cscript. Exe c: \ scripts \ retentionscript VBS 


2, set the timer task remove IIS log
(1) open the server manager, click the "tools" menu, then click on the "mission planning process,"

(2) in "task planning process" "actions" pane of the dialog box, click the "create a task,"

(3) in "create tasks" on the "general" TAB of the dialog box, enter the name of the task, such as "does iis logs", set the security properties, select a user account with sufficient privileges to run the script,

(4) click the triggers TAB, and then click new, in "the new trigger" dialog, set the "start task" to "scheduled", choose periodically, every day, for example, enter the start date, choose the more advanced Settings, if ready to plan, please make sure that has chosen "enable", click ok,

(5) click "action" TAB, and then click the "new", the "new action" dialog box, choose for "operation" a value, select "start Program", in "a Program or script", input cscript, in the "add parameters" (optional), type in the name of the path and the script file, such as C: \ Program Files \ cleaning IIS log script \ retentionscript VBS, click ok,

(6) in "create a task" dialog box, click ok,
(7) validation tasks have been added to the "active task pane; Right-click on the new task, and then select run,

(8) navigate to the script is running in the folder, and verify whether delete the appropriate log files,
(9) to navigate back to the "task planning process", right-click on the task, and then click the "end", in order to state to return to the "ready", and the task is ready for operation of the plan,
  • Related