SSH output redirection to file does overwriting instead of appending

Viewed 11

I am doing some tasks locally and save debug info to a log file. Then I try to do some other tasks remotely via SSH, and attempt to save the output into the same local file. SSH's output overwrites my log file from the beginning for some reason. For example:

root@localhost:~# echo "The quick brown fox jumps over the lazy dog. 1234567890" 1>"test.log";
root@localhost:~# cat "test.log";
The quick brown fox jumps over the lazy dog. 1234567890
root@localhost:~# echo "echo hello_world" | ssh root@192.168.1.2 "sh -s" 1>>"test.log";
root@localhost:~# cat "test.log";
hello_world
own fox jumps over the lazy dog. 1234567890

What should I do to make it append correctly?

P.S: hexdump -C "test.log"

00000000  68 65 6c 6c 6f 5f 77 6f  72 6c 64 0a 6f 77 6e 20  |hello_world.own |
00000010  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
00000020  68 65 20 6c 61 7a 79 20  64 6f 67 2e 20 31 32 33  |he lazy dog. 123|
00000030  34 35 36 37 38 39 30 0a                           |4567890.|
00000038
0 Answers
Related