[clug] Redirect time command output to file
Kevin Pulo
kev at pulo.com.au
Thu May 27 18:16:53 MDT 2010
On Fri, May 28, 2010 at 07:42:47AM +1000, Sam Couter wrote:
> Hal <hal.ashburner at gmail.com> wrote:
>
> > Ok Invoke the time binary explicitly
> >
> > /usr/bin/time --append -o logfile.log /path/to/timed/command 2>&1 >>
> > logfile.log
>
> And that's how you get around a bash built-in when you want to use the
> real thing, although your redirection is still the wrong way around.
Which reminds me - supposing you want to run a real command (not a
builtin), but you don't know (or care) the absolute path, and you
don't want to parse $PATH manually (nor should you), then the Right
Way to do it (in bash) is to use the "command" builtin.
$ time echo "foo"
foo
real 0m0.000s
user 0m0.000s
sys 0m0.000s
$ command time echo "foo"
foo
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 2384maxresident)k
0inputs+0outputs (0major+195minor)pagefaults 0swaps
$ type -p time
$ type -P time
/usr/bin/time
$ type -a command
command is a shell builtin
$
Kev.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/linux/attachments/20100528/c3dd1165/attachment.pgp>
More information about the linux
mailing list