Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to perform a "tail -f" from an url?

Tags:

linux

bash

tail

I currently use tail -f to monitor a log file: this way I get an autorefreshing console monitoring a web server.

Now, said webserver was moved to another host and I have no shell privileges for that. Nevertheless I have a .txt network path, which in the end is a log file which is constantly updated.

So, I'd like to do something like tail -f, but on that url. Would it be possible?In the end "in linux everything is a file" so..

like image 958
Phate Avatar asked Jul 08 '15 13:07

Phate


1 Answers

I wrote a simple bash script to fetch URL content each 2 seconds and compare with local file output.txt then append the diff to the same file

I wanted to stream AWS amplify logs in my Jenkins pipeline

while true; do comm -13 --output-delimiter="" <(cat output.txt) <(curl -s "$URL") >> output.txt; sleep 2; done

don't forget to create empty file output.txt file first

: > output.txt

view the stream :

tail -f output.txt

original comment : https://stackoverflow.com/a/62347827/2073339

UPDATE:

I found better solution using wget here:

while true; do wget -ca -o /dev/null -O output.txt "$URL"; sleep 2; done

https://superuser.com/a/514078/603774

like image 141
Khaled AbuShqear Avatar answered Oct 06 '22 00:10

Khaled AbuShqear