After coming across a server that had an Out of Memory issue from a commandline php-script, I discovered that default (vanilla 12.04 LTS server install) the cli php.ini
does not have a memory limit set.
myname@servername:~$ php -i | grep memory_limit
memory_limit => -1 => -1
myname@servername:~$
This was a brand new 12.04 install, choosing 'LAMP' during installation, especially set up for testing this default value.
This surpised me, and I'm wondering why this is so, and even if this is deliberate?
You can restrict your commandline scripts with max-execution-time
"This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0. ...
You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini."