PHP命令行:max_execution_time和memory_limit

Nat*_*n H 2 php

快问.

如果我从命令行运行一个PHP脚本(通过一个cron作业,"php ./somwthing-sync.php"),我仍然受限于php max_execution_time和memory_limit?

谢谢

弥敦道

gho*_*g74 10

如果你看一下这个文档,它说

      max_execution_time  integer

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.
Run Code Online (Sandbox Code Playgroud)

0表示无限制.(如果我没错的话).至于memory_limit,PHP命令行将获取php.ini中定义的值.通过编写"吃"内存并在php.ini中将memory_limit设置为-1的代码,您可以轻松地测试和查找

  • 不,你没错,理论上命令行的时间限制是无限的.事实上,PHP文档明确说明了这一点:http://us.php.net/manual/en/features.commandline.differences.php (2认同)