Clear windows log files

broken image

To run this script automatically, create a new job using Task Scheduler: PowerShell script that will remove all files older than 7 days in the directory C:\inetpub\logs with the *.log extension might be look like this: gci ‘C:\inetpub\logs -Include ‘*.log’ -Recurse | ? LastWriteTime -LT (Get-Date).AddDays(-7) | Remove-Item

You can do this manually (not the best choice), or automatically using PowerShell script that will be cleaning log files on schedule.

broken image
broken image

Try to open each subfolder in the directory %SystemDrive%\inetpub\logs\LogFiles, agreeing with the appointment of the necessary permission and eventually see that the real volume of folders is not so small.Īs a rule, you can safely remove all the log files older than 3-7 days.