Shell script best practices, from a decade of scripting things
One of my favorite shell script snippet is prepending timestamp to every output with the help of ts command of moreutils package, meanwhile write to log file at the same time:
<a href="https://unix.stackexchange.com/questions/26728/prepending-a-timestamp-to-each-line-of-output-from-a-command" rel="nofollow">https://unix.stackexchange.com/questions/26728/prepending-a-...</a><p>exec &> >( ts '[%Y-%m-%d.%H:%M:%S] ' | tee ${LOGFILENAME} )