miércoles, 28 de diciembre de 2022

WINDOWS. Scheduled Task. Delete logs

Purpose

Create a scheduled task to delete old logs on the server

Information

This commnad don't need install 

Steps

Connect to server, open Windows scheduled tasks

Create a basic Task:


Specify the SYSTEM user.


Create action:


COMMAND:   gci 'C:\inetpub\logs\LogFiles' -Include '*.log' -Recurse | ? LastWriteTime -LT (Get-Date).AddDays(-60) | Remove-Item

*gci alias is Get-ChildItem

by GoN | Published: December 28 2022 | Last Updated:

No hay comentarios: