Time command not creating log file

The time command is not working completely. It is not creating the log file.

# See how long it takes to open a document 
# Does not create log file
time /usr/lib/libreoffice/program/swriter --nologo  /home/andy/Documents/Blank.odt >> /home/andy/Downloads/log.txt 
# Warning: failed to read path from javaldx
# Known bug ?
sleep 2
echo marlin | sudo -S pkill soffice.bin

Probably because the redirection is applied to the nested command and not to time.
Also, the output of the time command is displayed via stderr

Try this:

 ( time /usr/lib/libreoffice/program/swriter --nologo  /home/andy/Documents/Blank.odt ) 2>> /home/andy/Downloads/log.txt

In this case we put the whole command in a subshell and redirect the stderr of the complete subshell to your logfile.


Thanks tkn.

The pkill never executes. Is that because of my closing the document in swriter?

Because the 'time' process is not backgrounded, sleep will be executed after the previous command (time soffice) has ended, which only happens when you close swriter.

You could try it this way:

swriter="/usr/lib/libreoffice/program/swriter --nologo  /home/andy/Documents/Blank.odt"

( time $swriter & sleep 2 && pkill soffice.bin ) 2>"$logfile"

Oh, btw, this:

Warning: failed to read path from javaldx
Known bug ?

no , it's just an innocent warning that "openjdk" is not installed (i.o.w. Java),
there are no further implications except the inability to perform java from within documents.

I don't have any need for openjdk so I have it not installed and therefore I also get this friendly message.

If you want the message to go away, install openjdk:

sudo apt install default-jdk