Unix time Question
Posted in 2007
Topics: Server Administration
Hi all;
Ya - I know - but I bet the answer is on this list.
I am in HP Unix, not that I think this will influence the answer.
I run something like :-
time ( dbaccess - <<! whatever ! 2>&1 >> log ) 2>&1 >> time.log #
The crt's are there
But the `time` always ends up on the tty and not in the file
'time.log'.
Man `time` says the times are on stderr, but this beats me and the
Platform guys !
Any idea's ?
Regards
Ian
On 17/08/07, ian <ipellew@yahoo.com> wrote:
> Hi all;
>
> Ya - I know - but I bet the answer is on this list.
>
> I am in HP Unix, not that I think this will influence the answer.
>
> I run something like :-
>
> time ( dbaccess - <<! whatever ! 2>&1 >> log ) 2>&1 >> time.log #
> The crt's are there
>
> But the `time` always ends up on the tty and not in the file
> 'time.log'.
>
> Man `time` says the times are on stderr, but this beats me and the
> Platform guys !
>
> Any idea's ?
>
> Regards
> Ian
>
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>
Ian
I always understood you had to redirect STDOUT before redirecting
STDERR to STDOUT. Try >> time.log 2>&1 at the end.
Keith
On Aug 17, 4:01 am, ian <ipel...@yahoo.com> wrote:
> Hi all;
>
> Ya - I know - but I bet the answer is on this list.
>
> I am in HP Unix, not that I think this will influence the answer.
>
> I run something like :-
>
> time ( dbaccess - <<! whatever ! 2>&1 >> log ) 2>&1 >> time.log #
> The crt's are there
>
> But the `time` always ends up on the tty and not in the file
> 'time.log'.
>
> Man `time` says the times are on stderr, but this beats me and the
> Platform guys !
>
> Any idea's ?
>
> Regards
> Ian
Keith is correct. On UNIX if you redirect STDERR to STDOUT then
redirect stdout the effect is:
Send stderr to where stdout is now going then redirect stdout
somewhere else. Also, if you redirect output from the subshell for
dbaccess and also the containing app's stdout/stderr to the same file,
there's a possibility that the output from one could stomp on the
other. Better to just let the inner shell's output flow through the
redirections of the caller.
So that should be:
time ( dbaccess - <<! whatever ! ) >> time.log 2>&1
Art S. Kagel
ian wrote:
> Hi all;
>
> Ya - I know - but I bet the answer is on this list.
>
> I am in HP Unix, not that I think this will influence the answer.
>
> I run something like :-
>
> time ( dbaccess - <<! whatever ! 2>&1 >> log ) 2>&1 >> time.log #
> The crt's are there
>
> But the `time` always ends up on the tty and not in the file
> 'time.log'.
>
> Man `time` says the times are on stderr, but this beats me and the
> Platform guys !
>
> Any idea's ?
The way I'd do it is:
( time dbaccess - <<! whatever ! ) >time.stdout 2>time.stderr
Or I could combine standard output and standard error along the lines
other people suggested.
Note that in a pipeline, you can do:
command1 2>&1 | command2
Now command2 gets to see the standard error (and standard output) of
command1.
And for timing SQL, I'd suggest:
sqlcmd -B <<!
whatever
!
That will give you sub-second timing on each command - at least, elapsed
time.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2007.0226 -- http://dbi.perl.org/