I'm trying to implement a "poor man's cron" to run my PHP script only every 10 minutes (if no one visits the page it doesn't run until someone does)
Here is what I have:
$current_time = time();
if($current_time >= $last_run + (60 * 10)) {
echo 'foo';
$last_run = time();
} else {
echo 'bar';
}
What I'm expecting to get is "foo" on the screen once and when I refresh the page I want to see "bar". If I refresh the page after 10 minutes it should be "foo" again for once and then "bar" until another 10 minutes has passed.
Currently it prints out "foo" all the time.
<meta http-equiv="refresh" content="600">