Need to create 2 log files

Hello, and thanks upfront for looking!

I've been searching the threads for a way to do this, and have come up empty. Then again I don't seem to use the right search criteria...

We have a driver script which logs output to files which are used to be viewed via an online scheduling tool:
$EXECDIR/$process >> $PROC_LOG_FILE 2>&1

Within the KSH script being called by the driver, we write to a different log file, which is used for ops support. The way it's set today, all we do is echo certain things to the local log file via "echo | tee -a $LOCAL_LOG_FILE" command. This is problematic because we don't capture all the STDOUT and STDERR in this log. I would like both log files to contain the same information without touching the command from the driver script.

Can someone help out?

Appreciate your help.
Thanks!
Pete

I don't understand what you're using 'echo' for at all.

Why not just run the same command the same way? command >> logfile 2>&1

Thanks for your reply Corona.

Basically we echo what we're going to do and write that to the local log. Then we run command, and it's STDOUT and STDERR is captured in the log file used for display on the web tool, but the local log file doesn't catpure this. I also would rather not do "cmd >> logfile 2>&1" for each of the commands in the script, so I was hoping there was an easier way to accomplish this....

Run the script itself with > logfile 2>&1 then?

Or at the top of the script:

# Redirect stdout into logfile
exec 1>logfile
# Redirect stderr into stdout
exec 2>&1

Within the ksh script possibly remove the existing "tee" commands and wrap the entire contents in a sub-shell:

#!/bin/ksh
# Preamble and set logfile variable
(

#Lines which output to stdout or stderr


) 2>&1 | tee -a $LOCAL_LOG_FILE

Thanks Methyl and Corona,

I believe the subshell method stands a chance at working the way I need it to. The issue with Corona's approach is that the local log file would contain all the output and the other would contain nothing. I'll try it out....