Albretch Mueller wrote:
> in this case however I can't get (Linux) time to log into the
> output+errors log file. It just spits its output on standard err (not
> the err + out I am trying to redirect it to)
> ~
> There must be some syntactic error in my statement. Can you see it?
Your example was ten times longer and more complicated than needed to
reproduce the issue.
> date > ${_ERR_OUT}; (time rsync --archive --verbose ${_SRC} ${_DEST} 2>&1 >&3 | tee ${_ERR} >&3) 3>> ${_ERR_OUT}; date >> ${_ERR_OUT}
Much easier like this:
$ time sleep 0.2 >out 2>&1
real 0m0.202s
user 0m0.004s
sys 0m0.000s
The reason is that time is a keyword for the shell.
$ type time
time is a shell keyword
It has shell help.
$ help time
There are many ways to do what you want but the easiest might be to
use a subshell and then redirect the output from the subshell.
$ (time sleep 0.2) 2>out
$ cat out
real 0m0.202s
user 0m0.000s
sys 0m0.000s
Therefore your example:
> date > ${_ERR_OUT}; (time rsync --archive --verbose ${_SRC} ${_DEST} 2>&1 >&3 | tee ${_ERR} >&3) 3>> ${_ERR_OUT}; date >> ${_ERR_OUT}
Tracing through fd3 and the tee forking and joining makes my brain
hurt and my eyes bleed! And what is with all of the leading
underscores and curly brackets? :-)
Please say in words what you are trying to do with stdout and stderr.
Are you wanting something like this?
date > $_ERR_OUT
(time rsync --archive --verbose $_SRC $_DEST) >>$_ERR_OUT 2>&1
date >> $_ERR_OUT
Bob
Attachment:
signature.asc
Description: Digital signature