Reputation: 453
I am just wondering, what is the maximum execution time of a laravel artisan command?
Is it unlimited like php shell scripts or does artisan / laravel have some kind of protection for unlimited looped commands?
Because I wanna make a command that runs forever, as long as the server is running. Is that possible with Laravel Artisan?
thanks
Upvotes: 4
Views: 10951
Reputation: 619
You can run a php application independently from any default config time limits:
php -d max_execution_time=0 script.php
P.S. Set max_execution_time in PHP CLI
Upvotes: 1
Reputation: 3606
Running php artisan
from the shell (or cron) uses the standard CLI configuration of PHP. So yes, a script run that way will not be time-constrained (by default). However, due to the design of PHP and limited memory efficiency, it's a good idea to set up the script with supervisor and memmon.
Here's an example Supervisor configuration, sourced from here:
[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
Upvotes: 2
Reputation: 60068
i am just wondering, what is the maximum execution time of a laravel artisan command?
If you run it via the command line - it can be indefinite.
Is it unlimited like php shell scripts or dose artisan / laravel have some kind of protection for unlimited looped commands?
There is no protection - you are free to do what you want.
because i wanna make a command that runs forever, as long as the server is running. Is that possible with Laravel Artisan?
I do something similar - I have a php artisan command that has currently been running for 89 days without issue so far. But as Aross mentioned below, the problem is that if the command does fail for some reason, you need to know about it.
Upvotes: 5
Reputation: 9221
The default is zero, means no time limit. Even though maximum execution time is 30 by default, this does not affect to command line processes.
Check the documentation from here :- http://php.net/manual/en/info.configuration.php#ini.max-execution-time
Hope this helps, Cheers!
Upvotes: 2