Answer the question
In order to leave comments, you need to log in
How to run a PHP console application on CentOS?
On Windows, I run a php application through the command line.
those. I call cmd.exe and write php /p/index.php there
The program works continuously for 5 days.
I don't want to leave a working computer.
There is a virtual server with ssh. CentOS
How can I run my php application on it.
Those. This is a console application, not a browser one.
Let's say through ssh I somehow start it, but I will need to close the ssh window, and what's next?
How to make it so that it can be launched, then after a while it will connect to the server and see this same console that everything is working there.
Remote desktop type.
And what other settings need to be set in php so that nothing is cut off (what timeouts are there, the number of connections with mysql, timeouts with mysql)?
Maybe there is a cheap option in terms of the server, so that you can organize this thing for 10 days, if my option described above cannot be done in any way.
Answer the question
In order to leave comments, you need to log in
screen -S myPHP
php myscript.php you press
ctrl+a and then after ctrl+a you press d
so you run a script in screen
to return to the script write
screen -r myPHP
instead of myPHP and myscript write that your
script execution time - setting max_execution_time in php.ini
Alternatively, you can use special control programs like supervisord . They run your program at system startup and can monitor its state, write the output from your program's stdout to a log, and so on.
About the first question. Either use screen (man screen) or run the command with nohup at the beginning and & at the end, then the process goes into the background and will not be interrupted when the session ends.
Regarding the second, well, set max_execution_time = -1, in theory it should be enough. What are the timeouts and the number of connections with mysql, we apparently have to guess without seeing the code, yeah.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question