Read Remote Server log.txt on Real-Time Local Server

Asked

Viewed 1,117 times

5

Those days passed the idea (I must have read somewhere and refreshed) of having a program on the local server that is synchronized with the remote server, where in this program I can see in real time the file of logs of the server, thus facilitating and speeding up the time to fix some mistake (which I supposedly requested was recorded there).

Is there a way? If so, which(s) would be(m)?

  • 5

    Yes. Your question is answered :)

  • Putz, rsrs. I forgot to ask which one :(

  • Which S.O. the client server uses?

  • Local is Windows 7, the remote is Linux.

3 answers

4


I know that in Windows when I need something like use the Plink, utility of Putty via SSH runs commands on a remote server bringing the output of the remote to Windows.

Something like that, for example:

plink DEBIAN_SSH cat /var/log/messages

Plink is an SSH utility so it does nothing more than run a command on the remote server and brings its output back, all using SSH.

So, if the local server is also Linux, you can use direct SSH:

ssh [USER-NAME]@[REMOTE-HOST] cat /var/log/messages
  • Obviously this command can only be executed as ROOT or if the user logging in has permission on VISUDO for example.

  • Remember also that you need to have an access key on the local server that allows remote connection without needing password on the remote server, otherwise the command will require password. See this link if you need to create a key pair for access.

But I believe this is the way.

If you want to track the log output in real time the correct command is:

tail -f /var/log/messages

References in the links and also in the link below.
http://www.cyberciti.biz/tips/linux-running-commands-on-a-remote-host.html

  • 1

    I will choose your answer because it is the simplest to do, in addition to being compatible with the way I want to proceed (windows -> linux). multitail seems to be a good one because the display is more functional and colorful, but it needs cygwin64 to emulate a Unix-like or linux dist behavior to run multitail (at least that’s what you implied..)

  • I also find it quite simple to use Putty and its utilities, use for several tasks and this you need is just one of them. It is one. Excellent tool to always have at hand!

3

Use the program multitail. With it you can see two (or more) logs at the same time, rendered in the command line in the same window or in separate windows.

Official website: http://www.vanheusden.com/multitail/

Some examples:

To view two local logs at the same time:

multitail /var/log/apache2/error.log /var/log/apache2/error.log.1

To view two local logs at the same time, each in one color:

multitail -ci green /var/log/yum.log -ci yellow -I /var/log/mysqld.log

To view two local logs in two columns:

multitail -s 2 /var/log/mysqld.log /var/log/xferlog

To view two remote logs, each on a machine at the same time:

multitail -l 'ssh [email protected] "tail -f /var/log/nginx/access.log"' -l 'ssh [email protected] "tail -f /var/log/nginx/access.log"'

2

If both servers use Linux as OS, a good option is to use SSHFS. This allows you to have a remote folder mounted as a partition on your local system and you don’t need any complicated configuration - just have SSH access to the remote server.

To mount a folder with remote server logs just do:

sshfs utilizador@sistema_remoto:/var/logs/nginx/ /opt/remote_logs

After that you will be able to read the remote logs from the folder /opt/remote_logs habitually.

Systems such as Ubuntu or Debian have the package sshfs already in their repositories.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.