On Mon, Jan 18, 2016 at 10:38 AM, Delan Azabani <[email protected]> wrote:
> Put the commands that are to be logged in a grouping command, and
> then apply 2>&1 to that grouping command:
>
> { cd ../compile/GENERIC.MP && \
> make clean && make && make install; } \
> 2>&1 | tee /var/log/build/buildsys.log
>
> Note that grouping commands that use braces (i.e. those that execute
> their commands in the current environment) require a semicolon before
> they are closed, but those with parentheses do not.
This may help me remember grouping syntax for real.
> If you want stdout and stderr to be logged to separate files, or
> you otherwise want to keep stdout and stderr separate, then a more
> complex dance is needed:
>
> { { cd ../compile/GENERIC.MP && \
> make clean && make && make install; } \
> 2>&3 | tee /var/log/build/buildsys.out.log; } \
> 3>&1 | tee /var/log/build/buildsys.err.log 1>&2
Thanks, Delan (and Nigel, off list, for the parentheses example).
--
Joel Rees