删除超过180天的IIS log文件 Del IIS logs older 180 days

I'm currently doing this using a very simple batch file script:

forfiles -p C:\inetpub\logs\LogFiles\ -s -m *.log -d -180 -c "cmd /C DEL @File"

I also made a Scheduled Task entry to launch it daily and even activated the file compression feature on that folder: all these things together fixed my problem with IIS files for good.

Explanation of the switches in the batch file:

参考链接:

https://serverfault.com/questions/65329/how-can-i-keep-iis-log-files-cleaned-up-regularly

https://stackoverflow.com/questions/6919275/iis-7-log-files-auto-delete/40711754#40711754

https://www.ryadel.com/en/manage-iis-log-files-purge-older-n-days-bat-file/