我知道通常使用 PHP CLI 是因为没有时间限制,主要是因为它不使用 Apache 线程/进程。
但是有什么方法可以为一些我不想拥有“无限时间”的自由而只想控制这些脚本的脚本显式设置 max_execution_time?
如果您认为在 superuser.com 上可能会更好地回答这个问题并且有权移动它,那就去做吧。 :)
编辑:我用谷歌搜索了一下,找到了正确的参数:
php -d max_execution_time=5 script.php
最佳答案
documentation表示在命令行模式下运行时,默认为 0(无限制)。它并不是说你不能覆盖它:
set_time_limit(10); // this way
ini_set('max_execution_time', 10); // or this way
编辑:我自己试了一下,效果符合预期。
F:\dev\www>c:php -f index.php
PHP Fatal error: Maximum execution time of 2 seconds exceeded in F:\dev\www\index.php on line 3
Fatal error: Maximum execution time of 2 seconds exceeded in F:\dev\www\index.php on line 3
https://stackoverflow.com/questions/5874950/
相关文章:
linux - 我需要 -D_REENTRANT 和 -pthreads 吗?
php - 如何在 Ubuntu 14.04 上更改 php-cli 版本?
linux - 如何在 AWS 上的 Amazon Linux AMI 中自动启动 node.js
mysql - 用于数据库备份的 Linux shell 脚本
linux - 如何使用 sed 通过灵活的键和值更改我的配置文件?
linux - 使用 linux 命令行 (bash) 从网络摄像头拍照
ruby-on-rails - 如何在 Linux 上使用 Ruby 2.0 改进 unicorn
ruby-on-rails - Ruby on Rails - 无法将 "\x89"从 ASCII-