Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a log file on remote server, and I need to tail -f it on local machine via ssh. The command is pretty trivial:

ssh -n user@domain.com 'tail -f /path/to/remote/file'

Initially it works just great, but after some time (probably 1-3 hours) it stops working: there are new lines in the remote log file, but it isn't updated here, on local machine. No error is echoed, it just stops working. I have to interrupt it by pressing Ctrl+C and restart the same command, and it starts working again, for some time.

Internet connection is 100% working, because at the same time I have interactive SSH session to the same remote server, and it keeps working always.

What could be the problem, how to solve it?

Just in case, I'd say what I'm trying to achieve: it's just about remote irssi notifications. I have a server on which irssi is always running in tmux session, and I want to receive notifications on my desktop. So that important events (start_notification/stop_notification) are written to the log file, and my local script reads this log and manages notifications (tray icon, sound, libnotify's event)

And, as I already said, it stops working after some time, until I restart it.

My desktop OS is Linux Mint 13 MATE, server OS is Debian 3.2.51-1

Any help appreciated.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You should check the


file on your server, it should have the following options enabled:

TCPKeepAlive yes
ClientAliveInterval 60

or when opening the connection use the following options in your ssh command:

ssh -o TCPKeepAlive=yes -o ClientAliveInterval=60

an other option is to just keep some action by running something like:

sh -c 'while echo "Still Active" ; do sleep 20 ; done'&

you could also put this in your login script so you do not need to enter this manually.

share|improve this answer
Thanks, I'll test it for some time to make sure, really hope it helps. But could you please elaborate on TCPKeepAlive=no? It sounds strangely, in case I want to keep connection alive :) –  Dmitry Frank Feb 22 '14 at 18:53
TCPKeepAlive does not always work and the default is yes (I think), instead of this mechanism we switch to a different system which actively asks every 15 seconds for a server reply to keep the connection alive. Maybe there is no need to disable the TCPKeepAlive but usually they do and there is no need for when you use ServerAliveInterval. –  Requist Feb 22 '14 at 19:00
Thanks, that helped. –  Dmitry Frank Feb 23 '14 at 6:57

Here is a simple solution with a collateral advantage (I'll let you guess):

ssh -n user@domain.com 'while : ; do
        date "+--  %H:%M:%S  --"
        sleep 20
        done &    
    tail -f /path/to/remote/file'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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