0

I want to write a file that does something every half minute, day and night, even after closing the browser. I use Windows7. I have already tried this to open a file called "HaalG3.php" every half minute.

<?php 
    $sec="30"; 
    $page = $_SERVER['PHP_SELF']; 
    ignore_user_abort(true); 
    set_time_limit(0); 
    $file = fopen("HaalG3.php","r"); 
    header("Refresh: $sec; url=$page"); 
?>

This works fine as long as the calling file is open. HaalG3.php is opened every half minute.
But when I close the calling file nothing happens. I have also added code from someone of Stack Overflow:

<?php 
    $sec="30"; 
    $page = $_SERVER['PHP_SELF']; 
    ignore_user_abort(true); 
    set_time_limit(0); 
    while (!file_exists('stop.txt')) {
        $file = fopen("HaalG3.php","r");  
        sleep(5);
    } 
    header("Refresh: $sec; url=$page"); 
?>

But when I use a while-loop I only see "Waiting for localhost" on the tab of Internet Explorer and nothing else happens.

Any help?

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57

0 Answers0