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
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 ?
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.
PHP Code:
<?php ini_set('memory_limit', '128M');
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks