Dynamically tail a log an outputing to an updated html page

Can anyone tell me how to dynamically "tail" a file an output it an updating html page in unix.  I was thinking of using a meta refresh or maybe some javascript but can remember how to do it.
Who is Participating?
binkzzConnect With a Mentor Commented:
You can't have javascript tail log files because for security reasons javascript can access neither serverside or clientside filesystems. The best you can really do is to tail straight into an html file that starts with:


And after that you do the `tail -f logfile >> htmlfile`.

I think that's the closest you can get to your solution without resulting to java applett solutions.

You can make the html page refresh every minute easily by using meta tags or just plain javascript, fi:

<body onload=setrefresh();>

<script language=javascript>
  function setrefresh()
    setTimeout ('document.history.go(0)', 60000);

That will force it to refresh every minute.

I'm not sure what you want to update the html page with, but say you have a script that allows single log entries into STDIN and uses them to update the html page. You can then easily use a command like:

tail -f /usr/local/apache/logs/error_log > myscript

Which should accomplish what you want it to.

To refresh an HTML page it's easier to use a meta-tag like this :
<Meta Http-equiv="Refresh" Content="30">
This will refresh every 30 seconds.
mraggAuthor Commented:
The part that I really needed to know was if the web page could do the tail - like if there was a java script that could tail the file.  I dont want to have a script that is constantly running. It is for a logfile.

The javascript portion was also what I wanted to know so I will award binkzz if no one else answer soon
mraggAuthor Commented:
I thought so, but just checking.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.