ROBOCOPY Logging help - Need to shrink.

Soldato
Joined
12 Jun 2012
Posts
3,918
Location
West Yorkshire
Hi Guys,

Quick question. Is their a script out there or anything that will help me with cutting down my Logs. Currently using the Log+ setting and have 5 log files all around 10GB each which takes days for the server to open.

I would love to find a way for a script to go in and delete say the first half or in a date range. Is this possible?
 
Soldato
Joined
25 Oct 2002
Posts
2,622
Is there a reason that you're appending to an existing log each time? Letting them build up to 10GB seems insane. You could attempt to create new files from the existing ones in VBScript using the FileSystemObject as a one off, but I wouldn't suggest doing this on a regular on-going basis. You may find there a robocopy log parsers which will do exactly this, rather than writing something yourself.

For the future perhaps a better approach may be to save individual date/time stamped log files and then have a script which periodically deletes logs over a certain age.
 

Deleted member 138126

D

Deleted member 138126

Why are you logging so verbosely? Just get it to log the errors, no?
 
Don
Joined
21 Oct 2002
Posts
46,750
Location
Parts Unknown
Set this as the log file name..

"%date:~6,4%-%date:~3,2%-%date:~0,2% robocopylog.txt"

This will name it "2016-12-25 robocopylog.txt" (if it was Christmas Day :) )

I'd get it to put the logs in a subfolder called "logs", if it's on an NTFS drive, set NTFS compression on that folder. -This really helps to keep txt file sizes in check, without harming performance.


edit.

-to all files txt files over 30 days old from that log folder, run this script..


forfiles /p "x:\path-of-folder\logs" /m *.txt /D -30 /C "cmd /c del @file"
 
Last edited:
Back
Top Bottom