10

I successfully mounted a local folder against a remote ssh host.

I now wanted to do a tail -500f my_text_file but it's not working very well. Although it does open tail and shows me the file contents, the -f part is definitely not working. It must have something to do with sshfs. When I do a regular ssh connection it works wonderfully.

Any pointers on how to fix this? I'm using the sshfs version one gets when doing a sudo apt install sshfs in Ubuntu.

2
  • 2
    Does running tail with ---disable-inotify [sic] make any difference? Does tail give you any warnings? Inotify that tail should be using by default is not supported by sshfs. Commented Feb 25, 2017 at 18:11
  • Regardless of whether that helps though, you can try to simulate the command with something like while true; do clear; tail -500 my_text_file; sleep 1; done Commented Feb 25, 2017 at 18:17

2 Answers 2

9

tail -f tries to use a file change notification mechanism (inotify). SSHFS, like any other FUSE filesystem, does not support this mechanism. Normally tail should discover this on its own. If that doesn't work, you can use the undocumented option ---disable-inotify (starting with three dashes, because it's an undocumented option) to force the use of polling mode which works on any filesystem.

tail ---disable-inotify -n 500 -f my_text_file 
2

sshfs is using sftp protocol to list and transfer files and in the sftp protocol (at least as it is implemented in OpenSSH), there is no possibility to notify your local tail about updates of the remote file.

As @vovick proposed, you can workaround that using various approaches, for example using polling. Or better way, run the tail directly on the remote server (unless it is sftp-only).

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.