Show a txt file on a webpage which updates every second

前端 未结 5 1732
失恋的感觉
失恋的感觉 2020-12-29 15:40

I\'m sort of shooting in the dark here; I have no knowledge how to do this so some pointers and/or links to helpful tutorials would be great:

I have a website that I

5条回答
  •  灰色年华
    2020-12-29 16:26

    There are various ways of doing this...

    You could look into long polling.

    Stick a meta refresh tag to refresh the page every X seconds.

    tail -f /path/to/log.log in terminal will open a live preview of the last few lines of that file - this is what I do if I need to read the error logs as I debug.

    Or simply refresh the page manually as you go, it might be annoying having the page change it's contents automatically.

    As you have said your file is very large, I would use the PHP file() function to just grab the first X amount of lines from a file to keep bandwith down and readability up!

提交回复
热议问题