Friday, 16 January 2009

How do I clean up my log files?

Create a scheduled task that will execute the following command:

C:\WINDOWS\system32\forfiles.exe /p C:\logs /s /m *.log /d -7 /c "CMD /C del @FILE"

This example recursively deletes "*.log" files older than 7 days. If you simply wanted to move the files, change the comannd parameter - this provides a nice way to archive.

For further information, see the Forfiles documentation.

No comments: