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
  • 1
    watch cat /var/run/volts will display it every 2s. change for your filename. Jul 7, 2016 at 14:27

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .