0

I am using this code inside my PHP File

<?php
set_time_limit(0);
// More code here
?>

But i am still getting timedout after 100 seconds, what should i do?

enter image description here

Josh Poor
  • 505
  • 1
  • 5
  • 12
  • Possible duplicate of [How to increase maximum execution time in php](https://stackoverflow.com/questions/16171132/how-to-increase-maximum-execution-time-in-php) – safin chacko Jul 07 '17 at 07:51
  • Seems like it's CloudFlare that will timeout out, not PHP. CF have no idea about the time out settings in your code. – M. Eriksson Jul 07 '17 at 07:51
  • oh god, this is not duplicate. I am doing what i found on those questions, but it is not working – Josh Poor Jul 07 '17 at 07:53
  • Well, I removed cloudflare and got this error now ........ http://prntscr.com/fsp3g7 – Josh Poor Jul 07 '17 at 08:07

1 Answers1

0

I suggest a cron-job approach for your problem. CLI called php scripts have no time limit. A shared host however may stop process that take more than X seconds - but I think is a good option for your issue.

If that doesn't work either, please give us more details on what you're trying to do in that PHP file. Maybe we can help you reduce the execution time of that script by changing the implementation.

  • I am trying to add Millions of rows in MySQL tables using php code. It will take 1 month (if the script run 24/7). Yes, i tried cron job...but looks like the cron job also stop after 100 seconds . I removed cloudflare and got this error, now what bro? http://prntscr.com/fsp3g7 – Josh Poor Jul 07 '17 at 08:53
  • Not necessarily. The first thing in this cases is to use batch insert. It's much faster to insert multiple columns in a single statement. I used this algorithm to implement it (with a batch of 20, but you can use up to 1000 I guess) https://github.com/tiranflorin/Deep-Skies-Symfony/blob/8951fe2aa36ddf6be27def8a6d9ea26afd7d6072/src/Dso/ObservationsLogBundle/Controller/EntriesController.php#L246 More about Insert Optimization: https://dev.mysql.com/doc/refman/5.7/en/insert-optimization.html and https://stackoverflow.com/questions/11904720/how-to-optimize-mysql-to-insert-millions-row – sw0rdfishhhhh Jul 07 '17 at 09:00