Scripts Thread, Need a command line utility to truncate or shrink a log file in Coding and Web Development; I'm writing a script to backup some files on a daily basis. The script handles getting rid of old backups ...
20th July 2010, 01:08 PM #1
Need a command line utility to truncate or shrink a log file
I'm writing a script to backup some files on a daily basis. The script handles getting rid of old backups automatically, but for ease of monitoring, results go into a single summary log. This log will obviosuly continue to grow over time and I want to be able to shrink the log when it reaches a certain size (let's say 1Mb). I could code this myself, but there must be something out there.....
20th July 2010, 02:56 PM #2
What I do in my kix scripts when I open the logfile is:
The second paramater determines whether the file is appended to or overwritten. In the case above, it is appended to until it reaches 50k. If it's 50k+, the content gets overwritten.
$ = RedirectOutput($logfile, GetFileSize($logfile) > 51200)
It may not be exactly what you want as you lose the previous content, but if you're logging this elsewhere and this is only a summary it may be an option to consider.
By ful56_uk in forum Windows Server 2008
Last Post: 26th May 2010, 07:45 PM
By ful56_uk in forum How do you do....it?
Last Post: 18th May 2010, 04:36 PM
By autoit in forum Scripts
Last Post: 9th April 2009, 07:33 AM
By OutToLunch in forum Windows
Last Post: 10th January 2007, 02:55 PM
By wesleyw in forum Windows
Last Post: 12th October 2006, 11:10 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)