Log output of a script to a file
Nice bit of bash fu I discovered today
Add this snippet to the top of scripts and the output of lines below will be tee’d to a logfile.
Handy for those scripts you always want a log of
#!/bin/bash
# log all output
[ -d ~/logs/ ] || mkdir ~/logs/
exec > >(tee -a ~/logs/${release}.log)
exec 2> >(tee -a ~/logs/${release}.log)
# do stuff ...