0

I am working on PHP script which runs in background and reloads every 30-60 seconds and generates output which writes on first two lines of the file. For example let's say I have a file named file.txt.

Output:

server1-online 
server2-online

I have a script which completes in every 8 seconds and on my index page, I need to show last status which was written in file.txt and override after every 8 seconds delay.

Sebastian Brosch
  • 42,106
  • 15
  • 72
  • 87
tester125
  • 21
  • 7
  • These two might be of interest https://stackoverflow.com/questions/9398690/keeping-ajax-timer-synchronised using Ajax on a timer - other comments recommend CRON http://stackoverflow.com/questions/34138306/php-timeout-pause-time-in-a-loop Also http://stackoverflow.com/questions/12383371/refresh-a-page-using-php – Steve Dec 08 '15 at 18:35
  • Might be useful for reading and displaying file http://stackoverflow.com/questions/33850820/parse-txt-files-and-turn-them-into-static-html-files/33851340#33851340 – Steve Dec 08 '15 at 19:00
  • You could add `include index.php;` to your background script so it could echo what gets written to the file on `index.php` each time it happens but you would need the browser open so it may not be practical. Maybe add window.open javascript with a conditional statement that stops a new window if it is already open. – Steve Dec 08 '15 at 22:50

0 Answers0