time + wget = file
Hi all,
I have the following command I'm trying to capture to a file but I'm unable to: Code:
time wget -O /dev/null www.example.com |
why do you use -O /dev/null?
|
Actually you are downloading a file, but with the -O /dev/null parameter you are directly sending it into non-existence. Have a look at
Code:
man wget |
Code:
wget smxi.org/smxi.zip -o test.txt && cat test.txt Code:
--2012-06-05 13:30:36-- http://smxi.org/smxi.zip |
time and the base output of wget both print to stderr. If you want to capture the printed output of the exact command above, use this:
Code:
time { wget -O /dev/null www.example.com ;} 2> outfile.txt The {...;} brackets are for command grouping. Maybe not necessary in this case, but I think it's better to always clearly frame whatever the time command is supposed to measure. It also allows you to set up separate redirections for both the inside and outside commands, if you want. You can also use (..) subshell grouping. |
Ahhh thx guyz!!!
@David the H. I tried your suggestion but it doesn't log the time portion: Code:
# time { wget -O /dev/null www.example.com ;} 2> outputfile |
The time command also has a -o option with which you can print the output to a file.
But don't use the bash inbuilt time as this does not have the logging option, instead use "/usr/bin/time". |
Hmm, that's odd. I could've sworn it was working when I tested it yesterday, but you're right. For some reason I can't quite fathom the curly-bracket command grouping isn't saving them both. The redirection is only being applied to the grouping.
But it does save them both when I use a subshell instead. Code:
time ( wget -O /dev/null www.example.com ) 2> outputfile |
All times are GMT -5. The time now is 08:57 AM. |