script log file (how)

Tech-Archive recommends: Speed Up your PC by fixing your registry



I have a DOS batch file I use for backing up certain files and then burning
them to DVD's using nero once a week.
The problem with my original script was that it didn't keep any logs of what
it did and/or when it fails. If anything fails I had to investigate it
manually (time consuming).

I've since modified it to redirect any "console" output to a text file and
inserted "you are here" type ECHO's throught the script. The output also
creates a new log file every year so a single log file doesn't get too big
if no one ever purges it. Now I have a record of the previous 1 to 52 runs
but the logs eventually take up space and become difficult to work with.

I want to modify the script to maintain a single log file and purge old
records as needed. I want it to be self contained and not grow out of
control.

Q1: Is there an easy way to keep an ongoing record of previous runs in a log
file AND also prevent the log file from ballooning into a huge file (I want
it be a maximum size of 1 MB, or only keep a certain number of runs if
possible)?

Here is a snippet of the script I run (working portions removed for
brevity):
[start]
echo start
echo copy files into archive
echo burn archive using nerocmd.exe
echo done
[end]

command= c:\scripts\burnit.bat >> burnit_log_%date:~10,4%.txt

Result:
-creates a "burnit_log_2007.txt" file and appends all output that would
normally be printed to the screen during each run
-burnit_log_2007.txt can grow to a large size if problems are encountered or
the file is never purged


.



Relevant Pages

  • Re: nohup job to monitor log files
    ... condition occurs in a log file. ... but this script seem to be missing some pieces. ... echo $JVMLogFileName>> $LogFileName ... You might use case instead of "echo $n7 | egrep", ...
    (comp.unix.shell)
  • Re: unix shell script ignores exit when in function that is piped to tee
    ... > I thought calling a function within a script did NOT create sub-shells. ... is going to be able to alter the log file to cover up any inappropriate ... entry in the log to the previous entry. ... The easiest way to use crypt to ...
    (comp.unix.shell)
  • The necessity of Setting Objects to Nothing
    ... But what happens when you've got a script that is running as ... Dim Servers, List, strComputer ... Set Folder = objFSO.GetFolder ... '~~~ Write the results of the number of users query to a log file. ...
    (microsoft.public.scripting.vbscript)
  • Re: nohup job to monitor log files
    ... condition occurs in a log file. ... but this script seem to be missing some pieces. ... echo $LogFileName> $LogFileName ... echo $JVMLogFileName>> $LogFileName ...
    (comp.unix.shell)
  • Re: CSVDE Importing
    ... > specify the log file path via the -j option. ... CSVDE imports can only be used to create new users ... Unfortunately, the syntax is a bit more involved than a simple csv file, ... which makes it a little more difficult to manage its content via script. ...
    (microsoft.public.windows.server.scripting)