Re: Best way to Collect Log
- From: invincible <imanuk2007@xxxxxxxxxxxxxx>
- Date: Wed, 11 Jun 2008 08:15:34 -0700 (PDT)
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
.
- Follow-Ups:
- Re: Best way to Collect Log
- From: Stephane CHAZELAS
- Re: Best way to Collect Log
- References:
- Best way to Collect Log
- From: invincible
- Re: Best way to Collect Log
- From: Stephane CHAZELAS
- Best way to Collect Log
- Prev by Date: Re: Best way to Collect Log
- Next by Date: Re: search and replace html text with an element?
- Previous by thread: Re: Best way to Collect Log
- Next by thread: Re: Best way to Collect Log
- Index(es):
Relevant Pages
|