There is a need to be in the background for a long time to execute a PHP script
The thinkphp framework we use
I took a look at the online use of cron
Use cron to request a URL address
Call up the thinkphp action
Feels like it's not particularly reasonable.
If you pass the URL, you'll have Nginx fpm.
Is it possible to directly access PHP files
But if you access PHP files directly
Automatic loading is also a problem
What do the great gods say!
Reply content:
There is a need to be in the background for a long time to execute a PHP script
The thinkphp framework we use
I took a look at the online use of cron
Use cron to request a URL address
Call up the thinkphp action
Feels like it's not particularly reasonable.
If you pass the URL, you'll have Nginx fpm.
Is it possible to directly access PHP files
But if you access PHP files directly
Automatic loading is also a problem
What do the great gods say!
First thinkphp is executed in support of CLI mode, and PHP index.php can be executed directly in the project directory Index/index
Then write a very simple script to run Thinkphp's command line
cli.sh
sh -c "cd /home/wwwroot/think3;php index.php index/index;"
And then crontab-e edit the task, assuming that every minute it executes is
*/1 * * * * /bin/sh /root/cli.sh
The above process is tested and passed under thinkphp3.2.3
Thinkphp also supports CLI mode