Memory exhausting issue
I have an issue regarding the cronjob.
I have written a cron job(a php script) to run on 7:15 AM every day. The php script is to parse a big XML file, and then update the database. But when this cron job is executed, I am getting mail (the cron error) as follows
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 35
bytes) in /scripts/class.XMLParser.php on line 121
In the 121 st line of this file is
$parser = xml_parser_create('ISO-8859-1');
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $vals, $index); //line 121
But what is strange is when I execute this file manually via URL, this is working fine. Only through cronjob, its showing this error. What may be the reason?
I had googled a lot, and as per some tutorials, I looked into my "memory_limit" php.ini configuration variable. It is like this
memory_limit = 128M ; Maximum amount of memory a script may consume (16MB)
I tried by increasing this as
memory_limit = 256M
Does this make sense? Still the error is same? Anybody have any idea like, why error comes through CRON JOB and NOT via URL ?
My cronjob entry for this one looks as follows
15 7 * * * /usr/bin/php -q /scripts/cron_squads.php
Please help me, I have already spent a lot of time for this....
Thanks in advance,
When run by cron the script is executed via the CLI interface, not the web interface, so it may be running under different configuration settings. You could try using ini_set() within the script itself to change the limit.
Thanks for your reply. I have used ini_set to change the memory limit instead of doing it directly in php.ini and the error has gone.
Thank you very much..
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)