1

I am having problem with a php script running from Cron (executed by php).

Script runs fine but crashes after using 512 mb, I can not understand why because I have set the script to use much more, and the server can handle it for sure.

The executed php file is located before the web folder (can this cause the problem?).

Php.ini is set to handle 8192M

What am I doing wrong here (this is declared on top of the executed php file)?

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '8191M');
//ini_set('memory_limit', -1);
ob_implicit_flush(true);
16
  • What is it doing anyway? Commented Nov 29, 2019 at 13:14
  • What exactly does “from Cron (executed by php)” mean? Commented Nov 29, 2019 at 13:16
  • 1
    it will almost certainly depend on what the script is doing - post some code. if it's running on a cron, the old job might not be ending before the new one starts for example Commented Nov 29, 2019 at 13:18
  • until you post some code of the script, we've no way to work out what the culprit is for the excessive memory usage Commented Nov 29, 2019 at 13:24
  • Sorry for my explanation, the script is executed with "php script.php" Same problem occurs if the script is running from the terminal or from cronjob. The script is not the problem, no need to show code. The script is a foreach loop going thru a big array and updating stock information. The script can use much more memory, that is what I want. Commented Nov 29, 2019 at 13:39

1 Answer 1

0

Try setting the memory limit on the command line, e.g.

php -d memory_limit=8191M <yourscript>.php
Sign up to request clarification or add additional context in comments.

1 Comment

Same problem using this method

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.