I'm running a script on my machine that produces a lot of output as it runs. I redirect that output to /dev/null
because I'm not interested in its contents, and I capture any errors in a file (since I only care if the script fails). However, the errors in the file do not include a timestamp.
Is there a way to append a timestamp to the stderr redirect? This is the command I have, but can't figure out how to add the timestamp:
myScript.sh 2>> logfile.txt 1>/dev/null
I can't modify myScript.sh to print a date so that's not an option either. I tried something like this:
myScript.sh 2>> logfile.txt << date
but that doesn't work.