Implementation of Delayed Execution of PHP Timed Task

  • 2021-07-21 08:03:47
  • OfStack


/*
|---------------------------
|PHP Timing task
|@ Black-eyed poet <www.chenwei.ws>
|---------------------------
*/
ignore_user_abort(true); // Ignore script abort when client disconnects (allow script 1 Direct execution) set_time_limit(0); // Set the maximum script execution time, 0 Unlimited do{
$fp = fopen('auto.txt', 'w'); if($fp)
{
$text = ' How do you do \n\r'; $count = 0; for($i=1; $i<10; $i++)
{
if(! $c = fwrite($fp, ' No. 1 '.$i.' Line: '.$text)) // Returns the number of characters written, or in case of failure false
{
echo ' No. 1 '.$i.' Write failed for the second time !';
} $count += $i;
}
} fclose($fp); sleep(60); // Delay 60 Second execution }while(true);


Related articles: