How to best capture and log scp output?

前端 未结 9 1224
栀梦
栀梦 2020-12-31 01:55

I am trying to capture output from an install script (that uses scp) and log it. However, I am not getting everything that scp is printing out, namely, the progress bar. <

9条回答
  •  梦毁少年i
    2020-12-31 02:37

    None of the answers here worked for me, I needed to recursively copy large directory with lot of files over long geo distance, so I wanted to log the progress (&& echo success! was by far not enough).

    What I finally engineered and somehow worked was:

    scp -vrC root@host:/path/to/directory . 2> copy.log &
    

    With -v doing the trick of verbose logging (-C allows compression and -r recursion).

    Grepping the logfile

    grep file copy.log | wc -l
    

    allowed me to see the number of files copied so far.

提交回复
热议问题