Re: Best way to Collect Log



On Jun 11, 3:29 pm, Stephane CHAZELAS <stephane_chaze...@xxxxxxxx>
wrote:
2008-06-11, 07:24(-07), invincible:
[...]> I have so far collected logs from my scripts using
echo ......>>LOGFILE .

I suppose there is a way through which you can define a log file at
the start of script and all the logs are then directed to that log
file. Can somebody explain me how this works ....? Apart from defining
variable LOG=location/xyz what else needs to be done in order to
accomplish this.

[...]

In a Bourne or POSIX script:

exec 3> LOGFILE

then:

echo ... >&3

or:

exec > LOGFILE

and then every standard output of every command (including echo
commands) goes to the LOGFILE without you having to do anything.

If you want to redirect the error output as well:

exec > LOGFILE 2>&1

Note that the behavior of many commands changes with to
buffering of their output when their standard output is not a
terminal (by doing the above, you make it a regular file
instead), so it may affect the ordering of the messages.

--
Stéphane

Stephane,

I basically use a ksh. How different is POSIX from ksh ?

Ciao
.



Relevant Pages

  • Re: email oracle errors
    ... but it won't find errors that I edited into the logfile. ... >> what that function does in a script to make it work? ... > It sends standard output and standard error to the bit bucket. ... options (they are available in GNU grep 2.5.1 but not traditional grep so ...
    (comp.unix.shell)
  • Re: Can you duplicate Standard Output WITHOUT tee command?
    ... redirecting standard output to logfile is not going to cut it for me. ... I think I may need to look at the script command. ... But the problem with this is that it turns off the standard output. ...
    (comp.unix.shell)
  • Re: Best way to Collect Log
    ... echo ......>>LOGFILE. ... In a Bourne or POSIX script: ... exec 3> LOGFILE ... and then every standard output of every command (including echo ...
    (comp.unix.shell)
  • RE: SP1 Install Errors
    ... I have received your logs files and emails. ... time difference between us, and as you know, SP1 log is a large file and we ... First attempt at executing script sp1_serv_uni.sql failed; ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)
  • RE: Domain Startup Scripting
    ... the following command always works and logs the appropriate info ... above which tells me it is accessing the script, ... could help me with troubleshooting a domain startup script routine. ... @echo off ...
    (microsoft.public.windows.server.scripting)