How to call another PHP script from a PHP script?

后端 未结 3 1476
情歌与酒
情歌与酒 2021-01-27 19:30

I have a PHP script that has a runtime of 34 seconds. But it dies after 30 seconds. I guess my webhost a time limit of 30 seconds.

I am thinking of splitting the script

3条回答
  •  甜味超标
    2021-01-27 20:09

    Running it as CLI will automatically eliminate time limit. You can use cron for that as described by Salman A. I have script that run for every 30 minutes. It does like this:

     $startTime + $timeLimit) && ($min >= 29 || $min >= 59) )
       {
          echo "STOPPING...
    \n"; return true; } else { return false; } } ?>

    Why I did that? because I've read somewhere that PHP is very bad at garbage collection. Therefore I kill it every 30 mins. It's not that robust. But, given the constraint of shared hosting. This is my best approach. You can use that as template.

提交回复
热议问题