3

I'm trying to log the output of a remote ssh command.

I'm current using

ssh USER@IP | tee -a ~/random.log

and then run the command I need to run on the remote server which then logs to random.log.

I need this to be able to run in the background, currently it exits when I quit/close terminal.

I cannot log on the remote server as it is a router with very little free space (>800kb).

Stephen
  • 33
  • 1
  • 3

2 Answers2

2

You can use screen on the local machine as well, to prevent stopping the exit if you close your terminal window.

screen

and in the screen session,

ssh USER@IP | tee -a ~/random.log

If you accidentally close the window, just use screen -r to reattach. Note that this will not survive a reboot of your local machine.

Sven
  • 97,248
  • 13
  • 177
  • 225
-2

Tested this pretty quick between two linux boxes and it seems to work alright:

ssh USER@IP "command_to_show_router_log" | tee -a (local_copy_filename)

I used "tail -f (logfile)" in the "command_to_show_router_log" but since you mentioned this is a router, your syntax might be different.

  • This doesn't run in the background and it's exactly the solution the OP came up with that didn't suit his needs. Read and understand the question before posting an answer. – Sven May 05 '14 at 15:04