T. Joseph CARTERWed Mar 30 22:14:12 PST 2005
On Wed, Mar 30, 2005 at 02:37:50PM -0800, Jim Beard wrote: > Howdy folks, > > It's time for my bi-weekly simple(for some!) unix/linux question! > I'm working on a shell script to automate some back ups using rsync. I > would like to know how long the rsync process takes to complete. In > order to do this I was hoping to execute the command with 'time' and > then capture time's output. The problem is that any output redirection > I append to the command (like ' > logfile.txt' gets applied to the > command, and not to time. Time supposedly has an option for this, but > I have likewise not been able to get this to execute correctly. > > I've tried: > > time -o test.txt ls > bash: -o: command not found > > real 0m0.002s > user 0m0.000s > sys 0m0.000s -o is not a valid option for time, according to my manpage. I've discovered that bash has the same issue that csh does. That is, it provides its own time builtin that is incompatible with the version in the manpage. If your variant of time has the -o option, then you can use '/usr/bin/time -o test.txt ls' just fine. Mine does not, so I have to use a redirect--but I have to redirect stderr rather than stdout. You do that with 2> instead of 1> or just > on its own.