Skip to content
Advertisement

Refresh site exactly every tenth minute (like Cron)

is there any options (PHP, JavaScript) how to refresh website exactly every 10th minute?

I got some crob job on server, and every 10th minute I’m reloading the online RTSP stream downloading, and after this reload the video on site get stuck, so I need reload the page every 10th minute after the cron job executed.

Thanks for hints.

Advertisement

Answer

Since you are waiting for an external event to occur (cronjob) then you might consider doing

  1. in the crojob write to a file to indicate that the job is complete

  2. in your html page use JavaScript setInterval() to make an AJAX call to see if the file exists

  3. the AJAX call should ‘look’ for the file. If it doesn’t exist then return false other wise delete the file and return true

  4. The JavaScript should act accordingly to the returned value.

Note: the setInterval() timing can not be relied upon as JavaScript takes a backseat to other events that are occurring on the page. Best set it to every 2 or 5 minutes.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement