Ref

https://stackoverflow.com/questions/18460186/writing-outputs-to-log-file-and-console

How to

Logs everything you do in a bash terminal to a file

exec > >(tee /tmp/bash_out_$(date +%Y%m%d%H%M%S)) 2>&1