For some cloud machines I'm launching, I'm trying to log to a specific file, syslog, and the terminal/console.
At the top of my machine setup/cloud-init scripts, I have the following:
#!/bin/bash exec &> >(tee "/tmp/box-setup.log" | logger -t box-setup) apt-get install -y some-package
This works great at sending output to a file and syslog, but it doesn't pipe to the output to the terminal.
Generally speaking not having terminal output isn't a huge problem except when I'm debugging from a remote console. When that happens, I'm completely blind because the console is blank as the bash script executes.
Is there a simple way using
bash redirection or whatever to pipe all output (standard output along with standard error) to a file, syslog, and the terminal simultaneously?
I'm running Ubuntu 16.04.