IIS服務生成的u_extend1日志文件過大,無法刪除的解決辦法


聲明:該文章屬於原創文章,如需轉載請聯系作者,還請知悉,謝謝!

 

方法一:朋友,先打開services.msc,然后在控制面板中停用IIS和web服務(如果你有站點也在托管狀態),然后再進行u_extend1.log日志的刪除。

ps:朋友有沒有配置Microsoft記錄的日志記錄選項,里面選定不記錄iis日志。

方法二:祭出Process Explorer v16.26 下面的連接就是下載地址,查找是那個進程占用着日志文件,kill掉,在回頭來刪除。

https://docs.microsoft.com/zh-cn/sysinternals/downloads/process-explorer

方法三:(powershell腳本管理):設置清除超過N天(30,90,180)的日志文件。下列范例為180天

 

# Script to be run weekly by task scheduler to cleanup IIS log files older than 180 days old.
$start = (get-date).AddDays(-180) 
Get-ChildItem -Path c:\inetpub\logs\logfiles\w3svc*\*.log | where {$PSItem.LastWriteTime -lt $start} | Remove-Item 

 

如果$PSItem.LastWriteTime字段報錯,你就改成$_.LastWriteTime

在提供一個批處理腳本,也是180天,注意下路徑

:: delete IIS files older than 180 days
:: -s or /S : recurse into all subfolders
:: -p or /P : path
:: -m or /M : file mask
:: -d or /D : number of days (-30 = older than 30 days)
:: -c or /C : command to execute
forfiles -p C:\inetpub\logs\LogFiles\ -s -m *.log -d -180 -c "cmd /C DEL @File"

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM