+ Post New Thread
Results 1 to 2 of 2
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 ...
  1. #1
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

    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.....

  2. #2
    Chad's Avatar
    Join Date
    May 2007
    Location
    Elgin
    Posts
    74
    Thank Post
    5
    Thanked 20 Times in 19 Posts
    Rep Power
    18
    Andy,

    What I do in my kix scripts when I open the logfile is:

    Code:
    $ = RedirectOutput($logfile, GetFileSize($logfile) > 51200)
    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.

    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.

SHARE:
+ Post New Thread

Similar Threads

  1. sql 2008 shrink log file
    By ful56_uk in forum Windows Server 2008
    Replies: 2
    Last Post: 26th May 2010, 07:45 PM
  2. how to shrink an ldf file
    By ful56_uk in forum How do you do....it?
    Replies: 2
    Last Post: 18th May 2010, 04:36 PM
  3. Replies: 9
    Last Post: 9th April 2009, 07:33 AM
  4. Replies: 5
    Last Post: 10th January 2007, 02:55 PM
  5. Command LIne
    By wesleyw in forum Windows
    Replies: 4
    Last Post: 12th October 2006, 11:10 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •