How do i run a php script every second?

后端 未结 5 1846
醉话见心
醉话见心 2020-12-20 08:51

I am currently writing a online game. Now I have to check if an event happen (checking timestamp in database) and depending on that execute some actions. I have to check for

5条回答
  •  旧时难觅i
    2020-12-20 09:45

    $total_time = 0;
    $start_time = microtime(true);
    while($total_time < 60)
      {
            //DoSomethingHere;
        echo $total_time."\n";
        //sleep(5);
      $total_time =  microtime(true) - $start_time ;
      } 
    

    add this in crontab to run every minute.

提交回复
热议问题