[英]Executing a php script with PHP
I have a php function to save multiple rows in database, I can't use this on the web requests since it takes much time. 我有一个php函数可在数据库中保存多行,但由于需要花费很多时间,因此无法在Web请求中使用此功能。 In the function, first I need to obtain a list of ids from database, do some processing, then save new set data into another table.
在函数中,首先需要从数据库中获取ID列表,进行一些处理,然后将新的设置数据保存到另一个表中。 Is it possible to run this script from php, for example from a controller?
是否可以从php(例如从控制器)运行此脚本?
Use shell_exec 使用shell_exec
$output = shell_exec('php YourFile.php');
OR 要么
exec EXEC
exec('php YourFile.php')
OR 要么
cronjob ( As @Thomas mentioned ) cronjob(如@Thomas所说)
* * * * * php /var/www/file.php >> /var/www/log/cron.log 2>&1
If you want to run it continuously set_time_limit(0) 如果要连续运行set_time_limit(0)
<?php
set_time_limit(0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.