I am trying to time the following command and eventually want to output the result to a file (hence the use of /usr/bin/time. However, the command being timed is always seq 1 2 rather than the entirety of the command:
/usr/bin/time -v seq 1 2 | parallel ssh-keygen -G /folder/{}.candidate -b 768
Is there a way to make sure the whole command is timed and not just the first little part?
If you are using bash it is easier to use the bash built-in:
$ time cmd1 | cmd2 | cmd3
will time the entire pipe.
If you really want to use the external time command, you have to run the pipe in a sub-shell:
$ /usr/bin/time sh -c 'cmd1 | cmd2 | cmd3'
or else you'd be piping the time instead of timing the pipe.
This syntax also has the nice side effect that it is easy to separate the output of the command and that of time:
$ /usr/bin/time sh -c 'cmd1 | cmd2 > cmdout.txt 2> cmderr.txt' 2>> time.txt
However, it has an extra difficulty in the quotes. If your command itself contains quotes, you may need to escape them in hard to read ways.