In the example above, all log files older than 180 days will be deleted. You can alter the command argument after the "/d" option to any desired number of days. Furthermore, substitute "<log dir>" for the actual directory where your logs are located. To automate this process, create a text file containing the above command, then change its file extension to .CMD. At this point the built-in Windows task scheduler can be used to run the command as often as desired.
NOTE: forfiles.exe is a part of the Windows Resource kit. If this file does not exist on your Windows 2003/2008 server, please install the Windows Resource Kit for your version of Windows.
Imported Document ID: 000010607
Subscribing will provide email updates when this Article is updated. Login is required.