开发者

Is it possible / how can I create a local copy of a live remote log file for watching / tailing?

Scenario: I can watch logs on the remote Unix machine using ssh and tail but I cannot install software. I want to use something like multitail or other log viewer which is not available on the remote machine to watch the log files. Of course, if I could find a way to create live local copies of the logs as they are being written, I can use what ever software I want on the local machine.

Question: W开发者_开发技巧ould it be possible to do something like re-direct the output of the ssh client to a file for this purpose or is there another way to accomplish this goal?


Use the -l option:

-l command
Command to execute in a window. Parameter is the command. Do not forget to use "'s if the external command needs parameters! (e.g. -l "ping host").

For example

$ multitail -l 'ssh host1 tail -f log1' -l 'ssh host2 tail -f log2'

Multitail doesn't seem to support bash process substitution, however.


Yes, you can do this by using netcat. Note that if you do not incorporate it into the chain, the log file will be sent over the network unencrypted, which can be a security risk for some log files.

The idea is that you use netcat, which basically works like a pipe over the network.

1. On the machine that holds the log file, do:

tail -f <logfile> | nc -l -p <port-number>

2. On the machine that wants to further process the file, do:

nc <first machine> <port-number> | <your file processor, e.g. multitail>

Or you can also write to a file on the target machine with '>' and then use multitail on that file. The port number is to be chosen by you, a 16bit number larger than 1024.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜