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.

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

Reply via email to