How a .bat file can control whether a file starts over new, or appends to an existing file and so grows to a large size in MailStream Plus, MAIL360 Manager and more

Operating System: Windows



.log file grows to GBs in size


The ‘>’ or ‘>>” in a .bat file controls whether a new file is created, or an existing file is appended to.
Using MAIL360 Manager as an example, the .bat file that calls Manager is what controls and writes to the .log file.  And it controls whether a new file is written, or whether data just keeps getting appended into the existing file. 
This is the first line that writes to the log file, from our test .bat file.  Notice the single '>' sign.  A single '>' means to start a *new* file-
DIR /ON "%G1IMBBATCH%\data"\%G1JOB%.* >"%G1IMBBATCH%"\data\%G1JOB%.LOG
The subsequent lines to write things to the log file have 2 ">".  Two '>>' signs means to *append* to the existing file-
ECHO ------------------------- >>"%G1IMBBATCH%"\data\%G1JOB%.LOG
A user had reported their log file was growing to a very large size (several GBs).  It was determined that they had modified the .bat file, and inadvertently left out the first line with the single '>'.  All of the lines had two '>>', which made all of the logging keep getting appended to the existing .log file, job after job.


UPDATED: April 12, 2017
When using .bat files, use of '>' will start a new file.