php 工匠命令的最大执行时间是多少



我只是想知道,laravel artisan命令的最大执行时间是多少?

它是无限的像php shell脚本或工匠/laravel有某种保护无限循环的命令?

因为我想要一个永远运行的命令,只要服务器在运行。这在Laravel Artisan中是否可行?

谢谢

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

如果您通过命令行运行它-它可以是不确定的。

它是否像php shell脚本或artisan/laravel一样不受限制对无限循环命令的某种保护?

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

因为我想要一个永远运行的命令,只要服务器正在运行。这在Laravel Artisan中是否可行?

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

默认为零,表示没有时间限制。即使最大执行时间默认为30,这也不会影响命令行进程。

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

希望这有帮助,干杯!

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

下面是一个示例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

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

php -d max_execution_time=0 script.php

注:设置max_execution_time

最新更新