Link to home
Start Free TrialLog in
Avatar of mragg
mragg

asked on

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.
Thanks
Avatar of binkzz
binkzz

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);
  }
</script>

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.

Tom.
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.
Avatar of mragg

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of binkzz
binkzz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mragg

ASKER

I thought so, but just checking.

Thanks