I have a bash script that is used for auto updating. I want to log all output of this script and prepend a timestamp to each line. I'm not sure how to add this to what I already have.
LOGFILE="logdir/update.sh.$(date +%Y-%m-%d_%H:%M).log" exec 1>$LOGFILE 2>&1
This redirects the output of my script to a file correctly, but there is (obviously) no date added to the line. How can I add this?
For instance, I want the logged output to look like this:
[2019-11-07 1:43:45 PM]: Ign http://security.debian.org jessie/updates InRelease
I'm not looking to prepend anything to each individual command my script has, I'm looking to prepend the timestamp and log each line any one command outputs globally throughout the script.