I have a cron script that sets up like the following, but the init.php never returns and there are 2 errors about running out of memory (256MB).
printf("Executing ".__FILE__."\n"); define('AREA', 'A'); define('AREA_NAME', 'admin'); define('ACCOUNT_TYPE', 'admin'); define('NO_SESSION', true);$addon_dir = “/app/addons/ez_shopify”;
$cur_dir = getcwd();
if( strpos($cur_dir, $addon_dir) ) {
// Seems some php installations chdir to the directory of this file
chdir(“…/…/…”);
}printf(“Current directory is: %s\n”, getcwd());
// And to get around bad usage of SCRIPT_FILENAME in the seo addon
if( empty($_SERVER[‘SCRIPT_FILENAME’]) )
$SERVER[‘SCRIPT_FILENAME’] = FILE;
// Various unprotected warnings from fn*() functions.
if(empty($_SERVER[‘REQUEST_METHOD’])) $_SERVER[‘REQUEST_METHOD’] = ‘GET’;
if(empty($_SERVER[‘REMOTE_ADDR’])) $_SERVER[‘REMOTE_ADDR’] = ‘127.0.0.1’;printf(“Set _SERVER variables, call init.php\n”);
require_once(“./init.php”);
use Tygh\Registry;
use Tygh\Mailer;
if( !defined(‘CONSOLE’) )
define(‘CONSOLE’, true);
ini_set(‘dipsplay_errors’, true);
error_reporting(E_ALL);printf(“Init done.\n”);
I get to the "Set _SERVER variables, call init.php\n" but the require_once("./init.php") just hangs for nearly a minute and then the error log contains:
# tail error_log [31-May-2019 17:29:37 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /home/XXXX/public_html/app/Tygh/Database/Connection.php on line 446 [31-May-2019 17:29:37 America/New_York] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /home/XXXX/public_html/app/Tygh/Registry.php on line 440
I tried to add a define('CONSOLE',true) early in the script but it then says it's already defined in Bootstrap.php.
I can't figure out what it's trying to do. I've also tried the more traditional approach of:
php /home/XXXX/public_html/adminpanelname.php --dispatch=addon_name.cron --cron_password=the_cron_password
Where I added a 'mode' to the addon controller called 'cron' which is supposed to call the function but it never gets there. I tried running other cron jobs that have been setup for other addons on the system and they all die with "exceeded memory limit" errors.
I can run ?dispatch=\addon_name.cron just fine from the URL, but not from a command line or cron.
Any thoughts?