1

This post 'Output file contents while they change' is similar but the answer doesn't work for my case. Tail -f doesn't seem to refresh the output when the file's size doesn't change or when there are no new rows added.

The file I'm trying to monitor/watch in SSH holds the value of a Volt Meter reading and it changes frequently (about every two or three seconds) but tail -f doesn't output the changes. Is there any other command similar to tail that can be used or does this require a custom binary?

  • 1
    watch cat /var/run/volts will display it every 2s. change for your filename. – Rui F Ribeiro Jul 7 '16 at 14:27
3

If the filesize doesn't change then the file isn't being appended to, it's being overwritten.

Depending on how the file is being rewritten, tail -F (capital F) may detect the change and rewrite it.

Otherwise if the file is small (e.g. just one line) then something like

while [ 1 ]
do
  cat file
  sleep 2
done

Will redisplay the file every 2 seconds. Fortunately there's a command that makes this easier

$ watch cat file

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.