1

I am trying to get a PHP script under local Linux Apache running without getting stopped by Apache. I am using PHP 5.5.9-1ubuntu4.4, Apache/2.4.7 (Ubuntu), Ubuntu 14.04 LTS 64-bit. What I did so far:

In my PHP script:

ignore_user_abort(true);
set_time_limit(0);
...
foreach(...) {
    ...
    // inside loop
    usleep(1000);
    ...
}

In all php.ini:

max_execution_time=3600;

Nothing of the above helped. The script stops after ~30sec. Im out of ideas. Is it possible that my script gets shut down because it runs out of memory? Best way to check that?

EDIT:

Through adding "ini_set('display_errors', 1);" I got the error Allowed memory size of 134217728 bytes exhausted. So it is about memory, thanks for the hint how to check that.

SOLUTION:

The underlying problem turned out to be the usage of 'foreach' loops. After switching all 'foreach' loops to 'for' loops the memory usage got more stable.

6
  • Do you launch your script from browser or from CLI? Commented Oct 29, 2014 at 12:30
  • Can you give us the error message that's shown? If you don't get one, add error_reporting(E_ALL);ini_set('display_errors', 1); to the top of the page Commented Oct 29, 2014 at 12:34
  • @TwiStar: browser - wasnt sure how well it would work from CLI since it's a whole framework (CodeIgniter) running. Commented Oct 29, 2014 at 12:36
  • @rjdown: E_ALL was already set but I added both of your statements in another place and now I get: "Allowed memory size of 134217728 bytes exhausted" Commented Oct 29, 2014 at 12:39
  • @rjdown: if you post your comment as reply, I shall accept it and close the issue! Thanks! Commented Oct 29, 2014 at 12:41

2 Answers 2

2

ini_set("max_execution_time", 0);
Only in http, if using https you must change your php.ini
Remember to reload your web server.

Sign up to request clarification or add additional context in comments.

Comments

0

To see what's causing the script to stop, add the following to the top of the page:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.