I send a tee
command from host 1 to host 2:
ssh user@host2 '/path/run |& tee myFile.txt'
I use tee
so that I get the output of the binary to be added to myFile.txt
The problem I have then is after a bit of time, I want to regain control of my local host without having a lot of printout. So I do CTRL+C. This lets the process on host2 continue to run, which is what I want, but it stops the tee
process itself, so the file is not populated.
I tried to replace |& tee myFile.txt'
by 2>&1 myFile.txt' &
but it did not help.
How can I ensure that the file continues to be populated on host2, while regaining control to my session on host1?