admin管理员组文章数量:1122832
Let's say I have a php file named get_data.php
Now I am running this file in cronjob passing a parameter like php get_data.php 1
. Now if there is 25 parameters then I have to run this file 25 times like
0 * * * * PHP get_data.php 1
0 * * * * PHP get_data.php 2
0 * * * * PHP get_data.php 3
0 * * * * PHP get_data.php 4
.
.
.
0 * * * * PHP get_data.php 25
Now I am looking for a solution to manage this easily. I want to make file all.php
and running it on cronjob. in all.php
I want to run all the get_data.php
file.
There are some ways to do this but it doesn't work in my case.
Include all
get_data.php
files in theall.php
file. This will runget_data.php
sequentially, but I want to run it parallelly.call all
get_data.php
files parallelly withcurl_multi
but that will use my webserver and it may cause a timeout issue. I want to run these files incli
Sorry if I don't make the question clear.
Let's say I have a php file named get_data.php
Now I am running this file in cronjob passing a parameter like php get_data.php 1
. Now if there is 25 parameters then I have to run this file 25 times like
0 * * * * PHP get_data.php 1
0 * * * * PHP get_data.php 2
0 * * * * PHP get_data.php 3
0 * * * * PHP get_data.php 4
.
.
.
0 * * * * PHP get_data.php 25
Now I am looking for a solution to manage this easily. I want to make file all.php
and running it on cronjob. in all.php
I want to run all the get_data.php
file.
There are some ways to do this but it doesn't work in my case.
Include all
get_data.php
files in theall.php
file. This will runget_data.php
sequentially, but I want to run it parallelly.call all
get_data.php
files parallelly withcurl_multi
but that will use my webserver and it may cause a timeout issue. I want to run these files incli
Sorry if I don't make the question clear.
Share Improve this question edited Nov 22, 2024 at 5:49 DarkBee 15.8k8 gold badges69 silver badges110 bronze badges asked Nov 22, 2024 at 4:28 Md. Sahadat HossainMd. Sahadat Hossain 3,2364 gold badges34 silver badges56 bronze badges 1 |1 Answer
Reset to default 1For such a simple command, you can use one line of bash command:
0 * * * * bash -c "for i in {1..25}; do PHP get_data.php \$i & done"
本文标签: phpHow to run multiple files from one file in parallelStack Overflow
版权声明:本文标题:php - How to run multiple files from one file in parallel? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736305626a1932656.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
nohup
or&
. Or you can usepcntl_fork()
(see this then). – Marcin Orlowski Commented Nov 22, 2024 at 4:43