0

I've got a server running Linux. There is a web application running in this server. And I'm trying to view log using command

tail -f /path/to/file.log

The problem is that my Terminal window is 80x24 and when I can only see the last 24 lines of log. When I try to scroll up, there are empty line (everything is erased).

And when I logout, everything printed during SSH session to terminal is erased.

I realize that in some cases it is a useful security feature, however in my case I need to disable it. How can I do that?

UPDATE: I recorded video https://vid.me/wvZj

  • 1
    What kind of terminal are you using? Regardless, if you run the ssh from something like screen or tmux you should be able to scroll and still see the output after exiting ssh – Eric Renouf Sep 9 '15 at 14:02
  • I think it's something server-specific because I use the same Terminal (build-in, Mac OS X) with other servers and it doesn't erase anything. – Anthony Ananich Sep 9 '15 at 14:07
  • "alternate screen" might be involved: superuser.com/questions/136162/… – thrig Sep 9 '15 at 14:09
  • May be you have a bash logout file on the remote server wich clean the terminal before logouting. – netmonk – netmonk Sep 9 '15 at 14:18
  • pipe the output through cat -v to stop the log using control chars to affect the terminal – meuh Sep 9 '15 at 14:25
0

You can just stream the file over SSH and print it locally on your terminal like so:

ssh <server_user>@<server_address> 'tail -f /path/to/file.log'

Or you can use a terminal multiplexer: screen or tmux. I use screen on a daily basis and it's a great tool. You SSH to a box, launch a screen session, do your stuff, then detach the session and log out from the server. Next time you SSH into that box you just run screen -r to reattach the session and you have the terminal in exactly the same state as you left it. Plus it has the option of scrolling the output.

  • Great suggestion, but the output erased anyway as soon as it goes out of the screen. – Anthony Ananich Sep 9 '15 at 14:14
  • @AnthonyAnanich Alright, this is intruguing :) You mean even with screen the output is truncated when it goes off the screen? Have you tried tailing over SSH? – Erathiel Sep 9 '15 at 14:18
  • Yes, you are correct. And it only happens in this one server. – Anthony Ananich Sep 9 '15 at 14:21
  • @Erathinel, I added video – Anthony Ananich Sep 9 '15 at 14:30
  • @AnthonyAnanich OK, this is weird. We know this is server-specific but is it user-specific as well or does it happen to all users on that particualr server? What I mean to track is whether this could be something related to sshd_config or rather something in the user's RC files. – Erathiel Sep 9 '15 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.