1
Can I tail -f
an output from http://example.com
?
I want to monitor external JSON file.
1
Can I tail -f
an output from http://example.com
?
I want to monitor external JSON file.
2
No. From the tail(1) man page:
With --follow (-f), tail defaults to following the file descriptor,
which means that even if a tail’ed file is renamed, tail will continue
to track its end. This default behavior is not desirable when you
really want to track the actual name of the file, not the file descrip-
tor (e.g., log rotation). Use --follow=name in that case. That causes
tail to track the named file in a way that accommodates renaming,
removal and creation.
This means that the tail command would need to the file descriptor to follow it, which it doesn't when you issue an http request. Your file system has no idea that a remote (in the sense that you are referring to) file has changed. To get something like this to work you would need to use a utility/script that polls the server at a specific interval or uses something like websockets (if the server supports that).
0
One way of doing this would be to run wget
on the target url in a loop and tail that:
$ while :; do
wget -qO - http://example.com >> /tmp/foo; sleep 1;
done
Then from another terminal run
$ tail -f /tmp/foo
0
To use tail -f
on an internet file you need that file to be locally readable and pollable. One way to accomplish that would be with HTTPFS, however this is not a commonly used or mature piece of software.
1How do you access this JSON file? Is it on a network share? On a pc to which you have ssh access? On the same machine under a different account?... – MariusMatutiae – 2014-01-18T13:24:00.730