Let's break that in to pieces:
exec
applies redirections on the shell itself, so indeed exec > somefile
would direct all later output from the shell and its children to that file.
Here, instead of a simple file name, we have the process substitution >( command... )
. It tells the shell to run the command inside, and to create a some filename that's connected to the input of that command. foo > >(bar)
is a bit like foo | bar
, except that process substitutions can be used for more complex cases too, and don't invoke subshells like the pipeline does. (<(command...)
would be the reverse, it would make the output of the command appear as if from a file.)
The command inside is tee filename | logger ...
. tee
copies its input both to stdout, and to the given file(s), and logger
sends its input to the system log. (The redirection 2>/dev/console
would apply to error output from logger
, probably it would print some errors if the system log doesn't work.)
Then there's the 2>&1
, which tells the shell to redirect error messages (stderr) also to that same process substitution.
So, after the redirection, everything the shell outputs (normal output and error output) goes (via tee
) both to the file and (via logger
) to syslog.
(I don't think any of that is specific to AWS or Linux, unless of course there's some particularities about the use of logger
on AWS.)
exec
combined with process substitution part is specific to bash - AFAIK, only bash allows that withexec
. Other Bourne-like shells require you to set up and use a fifo if you want to do that. See my answer to How can I redirect all output of a script to a file and replace passwords? – cas Sep 28 '21 at 14:28