Log Rotate

 
forfiles /p C:\WINDOWS\system32\Logfiles\W3SVC1 /m *.log /d -10 /c "cmd /c echo @FILE"

What this says is:

For all files in this directory (Windows logs for web server), with names matching *.log, more than 10 days old, execute this command "echo @FILE".

In our case, we want to remove files that have already been sent to stats.cats.ohiou.edu, (marked as .old, instead of .log), so we use this first one to test:

forfiles /p C:\WINDOWS\system32\Logfiles\W3SVC1 /m *.old /d -10 /c "cmd /c echo @FILE"

Execute this from the command prompt, and you'll see the list of files to be deleted.

If this is right, then change the .bat file as follows.

forfiles /p C:\WINDOWS\system32\Logfiles\W3SVC1 /m *.log /d -10 /c "cmd /c del @FILE"

and then schedule it to run at 5:55 or something early, but long after midnight, since that's when the logs get renamed and sent to stats.

Comments