I'm trying to have my page refresh ever 5 seconds to update data. Though Cron only runs every 1 minute. So I tried to incorporate into the page I'm loading a self refresh every 5 seconds.
My Cron job is:
/usr/bin/php /home/cplpc/public_html/commons/btc-fetch.php
This seems to update my code, though only once every minute.
The btc-fetch.php
page I've created is:
<?php
$page = $_SERVER['PHP_SELF'];
$sec = "5";
?>
<html>
<head>
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
<meta name="robots" content="noindex">
<meta name="googlebot" content="noindex">
</head>
<body>
<?php
$url = "https://www.bitstamp.net/api/ticker";
$fgc = file_get_contents($url);
file_put_contents('/home/cplpc/public_html/data/btc-the-price', $fgc);
echo $fgc;
?>
</body>
Any guidance or direction would be greatly appreciated. This script works if I have btc-fetch.php open in my browser, though I assume this is because 'it's in a browser'? Is there anyway to achieve the same desired task?
* Thanks for the replies
I'm using cPanel for the Cron Job. Perhaps I need to look at another way then PHP_SELF refresh. Thanks for the tips.