This command does not store the output of my script in the log file:. myscript.sh | tee -a log_file.logHowever this next command does store the output in the log file.. myscript.sh 2>&1 | tee -a dash_log.logWhy does the second one work and not the first? AFAIK the only difference is that I have told bash to redirect stderr to stdout, and it should not make any difference to what happens with stdout. Yet that first command would not even store the 'error-less' version of stdout in the log file.And in case it matters: I'm on Ubuntu 12.04 hosted on AWSEDIT: This was caused by erroneous assumptions of how wget outputs messages. See https://stackoverflow.com/questions/13066518/why-does-wget-output-to-stderr-rather-than-stdout and http://www.gnu.org/software/wget/manual/html_node/Logging-and-Input-File-Options.html
Why does this command work for logging script output?
ubuntu;logs;tee
It seems likely that your script is writing most or all of it's output to stderr.This is easy to testmyscript.sh > std.outmyscript.sh 2> err.outthen look at the contents of each file and be educated.I doubt it - the only output from the script comes from calls to wgetInstead of doubting, again this is easy to test$ wget http://serverfault.com >std.out--2013-09-09 07:06:25--  http://serverfault.com/Resolving serverfault.com... 198.252.206.16Connecting to serverfault.com|198.252.206.16|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 51867 (51K) [text/html]Saving to: index.html.6100%[=================================================>] 51,867   231K/s  in 0.2s2013-09-09 07:06:26 (231 KB/s) - index.html.6 saved [51867/51867]See, output still gets written to the terminal then try $ wget http://serverfault.com 2>err.out $Q.E.D.The wget command writes it's output to stderr not stdout.