today I was working with very large log files and I want to display them via lighttpd on my RPi, but they grow bigger every day and thus soon will take a very long time to load.
To prevent this problem I figured I would be able to have a button to read, say the last 500 lines from this log file. Of course I have not much experience with javascript, but I think it is doable, right?
Anyway, I couldn't find any good tutorial describing how to do this in javascript, although I found this in PHP, but since I'm not working in PHP I cannot use it. So, a example of how to read the last 500 lines in javascript or maybe a button to progressively read 500 lines every time you click on a button starting from the end of the file would be extremely handful for me.
Thanks in advance, guys.
(P.S: I've read it's not possible to read a file with javascript, but with AJAX calls it is possible.)
No, it's not possible with JavaScript. The client makes a request for a resource at a uniform resource locator - it's up to your server to serve up the last 500 lines if that's the desired response.
Simple unix command tail -500 mylog
can be interpreted by a number of server-side scripting languages if PHP isn't available to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With