什么是最大值php artisan命令的执行时间

问题描述 投票:2回答:4

我只是想知道,laravel工匠命令的最长执行时间是多少?

它是无限的像PHP shell脚本还是artisan / laravel对无限循环命令有某种保护?

因为我想制作一个永远运行的命令,只要服务器正在运行。 Laravel Artisan可以吗?

谢谢

php laravel-4
4个回答
2
投票

我只是想知道,laravel工匠命令的最长执行时间是多少?

如果通过命令行运行它 - 它可以是无限期的。

它是无限的像PHP shell脚本或剂量artisan / laravel对无限循环命令有某种保护?

没有保护 - 你可以自由地做你想做的事。

因为我想制作一个永远运行的命令,只要服务器正在运行。 Laravel Artisan可以吗?

我做了类似的事情 - 我有一个php artisan命令,目前已经运行了89天没有问题到目前为止。但正如下面提到的Aross,问题是如果命令由于某种原因确实失败了,你需要知道它。


1
投票

默认值为零,表示没有时间限制。尽管默认情况下最大执行时间为30,但这不会影响命令行进程。

从这里查看文档: - http://php.net/manual/en/info.configuration.php#ini.max-execution-time

希望这会有所帮助,干杯!


1
投票

从shell(或cron)运行php artisan使用PHP的标准CLI配置。所以是的,以这种方式运行的脚本不会受时间限制(默认情况下)。但是,由于PHP的设计和有限的内存效率,使用supervisor和memmon设置脚本是个好主意。

以下是来自here的Supervisor配置示例:

[supervisord]
logfile = /tmp/supervisord.log
#loglevel = debug

# Try keeping your-app running at all times.
[program:your-app]
command=/your/app
autostart=true
autorestart=true
startsecs=5
startretries=3
stopsignal=TERM
stopwaitsecs=10
log_stdout=true
log_stderr=true
logfile=/tmp/your-app.log
logfile_maxbytes=10MB
logfile_backups=10

# Restart your-app when it's using more than 50MB of memory
[eventlistener:memmon]
command=memmon -p your-app=50MB
# Check every 60 seconds
events=TICK_60

# The eventlistener plugin depends on [rpcinterface:supervisor] and a server
# [inet_http_server] or [unix_http_server] to communicate to the supervisor.
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisord]
logfile = /tmp/supervisord.log
#loglevel = debug

[inet_http_server]
port = 9001

0
投票

您可以独立于任何默认配置时间限制运行php应用程序:

php -d max_execution_time=0 script.php

附: Set max_execution_time in PHP CLI

© www.soinside.com 2019 - 2024. All rights reserved.