我正在尝试logging远程ssh命令的输出。
我目前正在使用
ssh USER@IP | tee -a ~/random.log
然后运行我需要在远程服务器上运行的命令,然后login到random.log。
我需要这个能够在后台运行,目前它退出时,我退出/closuresterminal。
我无法login远程服务器,因为它是一个可用空间非常小(> 800kb)的路由器。
您也可以在本地机器上使用屏幕,以防止在closuresterminal窗口时停止退出。
screen
并在屏幕上,
ssh USER@IP | tee -a ~/random.log
如果不小心closures了窗口,只需使用screen -r重新附加。 请注意,在本地计算机重新启动后,这将无法继续。
testing了这两个Linux机箱之间的这个很快,它似乎工作正常:
ssh USER@IP "command_to_show_router_log" | tee -a (local_copy_filename)
我在“command_to_show_router_log”中使用了“tail -f(logfile)”,但由于您提到这是一个路由器,您的语法可能会有所不同。